我如何通过jsoup解析由cloudflare保护的网站上的html

时间:2015-11-23 11:51:43

标签: java jsoup

代码为:

Document doc = Jsoup.connect("https://www.xxxxx.com/") //Website using cloudflare
                .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36")
                .followRedirects(true)
                .get();
        System.out.println(doc);

结果

Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=503, URL=https://xxxxx.com
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:537)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:493)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:205)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:194)
    at model.test2.main(test2.java:23)
Java Result: 1

如何通过jsoup在受cloudflare保护的网站上解析html。

0 个答案:

没有答案