How to copy content from web page with Java?

Asked

Viewed 56 times

0

I need to copy the contents of a web page, that according to the Dropdown selected displays the content, are n dropdowns my need would be to copy all content from that page.

That’s possible?

  • Take a look at this url: https://alvinalexander.com/java/edu/pj/pj010011 Ai has a tutorial on how to get the content of a JAVA url, it might be useful

  • @Matheussuffi answered my question, thanks for the help

1 answer

2


I managed with the following code to solve my need:

URL url = null;
File file = new File("C:\\Backup\\page.html");
BufferedWriter outFile = new BufferedWriter(new FileWriter(file));
def x = 1;
url = new URL("http://site");

BufferedReader inFile = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;

while ((inputLine = inFile.readLine()) != null) {
    logger.info(inputLine.toString())
    outFile.write(inputLine);
    outFile.newLine();
}
logger.info("RAMO: "+x.toString())
x++

inFile.close();
outFile.flush();
outFile.close();

I hope this helps the next.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.