Basic Scraping in Java with Jsoup

0

I have a simple form this way

<!DOCTYPE html>
<html>
<head>
<title>INICIO</title>
</head>
<body>

<div align="center">
    <legend>INGRESO</legend>
    <form action="evaluar.php" method="post">
        <label>NOMBRE</label>
    <input type="text" name="txtnombre"><br>
        <label>APELLIDO</label>
        <input type="text" name="txtapellido"><br>
    <select name="cbonivel"> 
        <option value="Secundaria">Secundaria</option>
        <option value="Primaria">Primaria</option>
        <option  value="Seleccione" selected>Seleccione un nivel</option>
    </select>
    <br>
    <input type="submit" name="btningresar">

    </form>

</div>

In this way:

to Obtain Data:

How would you get that data in JAVA

 public static void main(String [] args) throws IOException{

       Document docu=Jsoup.connect("http://localhost/SCRAPING/inicio.html").data("txtnombre","JOSE")
               .data("txtapellido","CASTILLO").userAgent("Mozilla").post();

       System.out.println(docu);  
        }

} If you could help me please

    
asked by Jcastillo 18.11.2017 в 23:51
source

2 answers

1

My advice is that if you want to save the information of a form and show it in a table, save the fields in a plain text document .txt and then parse it with php to format it with each line with f_of and loop for valible.lenght. And if you do not want to save the data and you want to show them after entering them, you collect the variables and the samples in the form of a table playing with echo 'code' "text" in php.

    
answered by 19.11.2017 в 00:26
0

You can use the Selenium tool

public class RobotSelenium {
private WebDriver robot;

public RobotSelenium() {
    System.setProperty("webdriver.gecko.driver","/home/andy/NetBeansProjects/librerias/selenium/geckodriver");
    robot= new FirefoxDriver();
}

private String abriendoPagina(String direccionWeb){        
 robot.get(direccionWeb);

 String pageSource = robot.getPageSource(); // aqui se almacena toda la informacion de la pagina. Luego se puede crear cualquier metodo de busqueda dentro del String

 robot.close();

 return pageSource;
}  }
    
answered by 30.11.2017 в 00:28