在java中如何比getResponseCode更快地获取http响应代码?
我想要获得超过 10000000 个网站的 http 响应代码。所以,我在java中使用了Http(s)?URLConnection类。
代码是
HttpURLConnection http = (HttpURLConnection)address.openConnection();
http.setReadTimeout(300000);
return http.getResponseCode();
但我认为它很慢。算了一下总时间,已经有10多天了。
你知道在Java中获取HTTP响应代码的更快速的函数或其他方法吗?
I want to get http response code of over 10000000 web sites. So, I used Http(s)?URLConnection class in java.
Code is
HttpURLConnection http = (HttpURLConnection)address.openConnection();
http.setReadTimeout(300000);
return http.getResponseCode();
But I think that it is very slow. When I calculate total time, it is over 10days.
Do you know more fast function or other ways to get HTTP response code in Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用多线程; 1000 个线程池将使您的运行时间减少 1000 倍。
使用非阻塞 I/O。运行 1000 个并发连接将使总时间减少 1000 倍。
Use multiple threads; a pool of 1000 threads will drop your elapsed time by a factor of 1000.
Use non-blocking I/O. Running 1000 concurrent connections will drop your total time by a factor of 1000.