Java – jsup cannot get the complete content from the web page [no error / exception, but some content is missed]

I'm trying to get content from the following page using jsoup:

http://www.exchangeandmart.co.uk/used-cars-for-sale

But it will not get the div with id = results, even if it is visible when the same link is opened from the browser Please help me

Java code:

Connection connection = Jsoup.connect("http://www.exchangeandmart.co.uk/used-cars-for-sale");
Document doc = connection.get();
System.out.println(doc.getElementById("results")); // prints null

Note: there are no exceptions or errors when downloading the page Only some content in the page is missing I use system out. Println (DOC) prints the entire document on the console;, It is completely different from the page I view in the browser

Solution

Document doc = Jsoup. connect(“ http://www.exchangeandmart.co.uk/used-cars-for-sale ”). userAgent(“Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 535.2(KHTML,like Gecko)Chrome / 15.0.874.120 Safari / 535.2“).get();

The page should now be rendered as accessed from chrome on your PC

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>