【发布时间】:2014-06-28 22:10:09
【问题描述】:
线程“主”org.jsoup.HttpStatusException 中的异常:获取 URL 的 HTTP 错误。状态=403,URL=(站点) 在 org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:449) 在 org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:465) 在 org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:424) 在 org.jsoup.helper.HttpConnection.execute(HttpConnection.java:178) 在 org.jsoup.helper.HttpConnection.get(HttpConnection.java:167) 在 plan.URLReader.main(URLReader.java:21)
大家好!
我一直在寻找一种在我的网站上为我正在开发的应用程序读取目录的方法。
如果我对其进行硬编码,我可以自己读取文件并使用它们,但是如果我尝试从目录中获取文件列表,则会收到此错误。
我尝试了几种方法,但这是我目前正在使用的代码。
String url = ""//(出于隐私考虑已删除网站); print("正在获取 %s...", url);
Document doc = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36").get();
Elements links = doc.select("a[href]");
Elements media = doc.select("[src]");
Elements imports = doc.select("link[href]");
... ... ...
现在,如果我使用 www.google.com/ 中的主站点,它会读取链接。问题是我想要一个目录,如 www.google.com/something/something/...
当我为我的网站尝试时,我收到了这个错误。
知道为什么我可以访问我的主站点,但不能访问其中的目录吗?
我还注意到末尾需要“/”。
只是好奇我是否错过了什么,或者需要以其他方式做某事?
感谢您的宝贵时间。
【问题讨论】:
标签: directory jsoup http-status-code-403 virtual-directory