【发布时间】:2015-03-26 14:20:47
【问题描述】:
我正在实现网络爬虫,我正在使用InetAddress 类从域名中获取 IP 地址。我尝试了域名 en.wikipedia.org 并获得了 ip 208.80.154.224。现在我正在尝试使用 jSoup 解析器从该服务器获取page /wiki/Cricket,但出现如下错误
Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=404, URL=http://208.80.154.224/wiki/Cricket
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:459)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:434)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:181)
at OtherClasses.TestDownloadJSoup.main(TestDownloadJSoup.java:30)
Java Result: 1
我获取页面的代码是
Connection con = Jsoup.connect("http://208.80.154.224/wiki/Cricket")
.userAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
.timeout(1000*5)
.followRedirects(true)
.referrer("http://www.google.com");
我应该怎么做才能解决这个 404 错误,即使我在浏览器中写了这个 ip,它给出的域没有在这个服务器上配置错误
【问题讨论】: