【发布时间】:2019-12-29 17:30:07
【问题描述】:
现在,在你说有这样的问题之前,我想指出我已经查看了大部分问题,但没有任何运气。另外我是第一次来这里所以要温柔。
我现在在我当前的程序中有这样的烦恼:
我的程序的这一部分基本上使用搜索引擎来查找 torrent 文件。
public static ArrayList<String> search(String args) throws IOException {
args = args.replace(":", "");
ArrayList<String> list = new ArrayList<String>();
URL url = new URL("http://pirateproxy.net/search/" + args + "/");
URLConnection con = url.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); <---- THIS
}
public static void main(String[] args) {
try {
search("The Hobbit: The Desolation of Smaug");
} catch (IOException e) {
e.printStackTrace();
}
}
错误:
java.io.IOException: Invalid Http response
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at service.ServiceDownloader.search(ServiceDownloader.java:20)
at service.ServiceDownloader.main(ServiceDownloader.java:45)
现在有趣的是,只有这部电影(“霍比特人:史矛革之战”)出错了,其他所有电影都完美无缺。我不明白这一点。请帮忙。 (另外我已经从搜索方法中删除了所有不必要的代码)
如果我在这里没有提供足够的信息,请向我询问更多信息。
【问题讨论】:
-
您在运行时传递的 args 值是多少?您是否手动检查了打开您尝试从代码访问的相同 URL
-
"pirateproxy.net/search/The Hobbit The Desolation of Smaug/" 如果我复制粘贴到地址栏中,效果很好。
标签: java httpresponse httpurlconnection ioexception