java.io.IOException: 服务器返回 HTTP 响应代码: 500
2022-09-02 20:19:54
我在Java上遇到了这个问题。我想从 URL 获取一些 HTML 信息。这段代码工作了很长时间,但突然间,它停止工作了。
当我使用浏览器访问此URL时,它会打开,没有问题。
代码:
URL site = new URL(this.url);
java.net.URLConnection yc = site.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
String objetivo = "<td height=\"28\" colspan=\"2\"";
while ((inputLine = in.readLine()) != null && !inputLine.contains(objetivo)) {
}
inputLine = in.readLine();
例外情况:
java.io.IOException: Server returned HTTP response code: 500 for URL: http://www.myurl.com
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at Sites.websites.Site1.getData(Site1.java:53)
at util.Util.lerArquivo(Util.java:278)
at util.Util.main(Util.java:983)
怎么了?房东屏蔽了我吗?