'How to script data from whole pages using jsoup Java
I am learning Java by myself and have a question about web scraping.
I tried to scrape data using jsoup, but I found that I only can scrape data from the current page instead of the whole pages. How can I get all data from the whole pages?
Here is the code:
String url = "https://www.example.com/homes/for_sale/xxx_rb/";
Document document = Jsoup.parse(new URL(url), 30000);
Elements elements = document.getElementsByClass("list-card list-card-additional-attribution list-card-additional-attribution-space list-card_not-saved");
for (Element el: elements){
String address = el.getElementsByClass("list-card-addr").eq(0).text();
String price = el.getElementsByClass("list-card-price").eq(0).text();
String detail = el.getElementsByClass("list-card-details").eq(0).text();
String pic = el.getElementsByTag("img").eq(0).attr("src");
System.out.println(pic);
System.out.println(price);
System.out.println(detail);
System.out.println(address);
BTW, if there is any comment for my code, please do not hesitate to let me know.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
