我想刮擦网站的内容,但似乎不起作用:
public static void main(String[] args) throws Exception {
String url = "https://www.rl-trades.com";
Document doc = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36").get();
System.out.println(doc);
}
我得到的是:
<html>
<head></head>
<body></body>
</html>
这个问题似乎是网站,因为这里问的每个类似的问题都对我有用。我还尝试了这个更高级的版本,但是我得到了完全相同的结果:
public static void main(String[] args) throws Exception {
String url = "https://www.rl-trades.com";
Response response= Jsoup.connect(url)
.ignoreContentType(true)
.userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
.referrer("http://www.google.com")
.timeout(12000)
.followRedirects(true)
.execute();
Document doc = response.parse();
System.out.println(doc);
}
有什么办法仍然可以获取内容?还是在没有工作的网站上只有刮擦保护?
预先感谢!
看起来这个网站喜欢接受语言标题:
String url = "https://www.rl-trades.com";
Connection connection = Jsoup.connect(url);
connection.header("Accept-Language","en");
Document doc = connection.get();
System.out.println(doc);