开发者

fater web page source provider

开发者 https://www.devze.com 2023-02-28 08:57 出处:网络
I am trying to pull page source in java with proxy. I have used开发者_StackOverflow httpclient, httpunit and HttpURLConnection, all of this taking 5 sec when i goes for page source without proxy but

I am trying to pull page source in java with proxy.

I have used开发者_StackOverflow httpclient, httpunit and HttpURLConnection, all of this taking 5 sec when i goes for page source without proxy but I uses proxy then its taking 12-15 sec for a single page.

Is there any way to increase speed or another class which is providing fast page source.


You need to identify where the problem is first: is it the case that the server you are pulling the pages from is really slow or is it the fact that the proxy you use is really slow (or both)? If you use the likes of wget (or probably even curl) in the command line that should show you statistics about the download time of the page -- through proxy and bypassing the proxy. If those times are the same with what your code shows then there's nothing you can optimise. If however, you see discrepancies then you can look at using other ways of pulling the pages in your code. As a general rule of thumb:

  • use Java NIO if you're dealing with lots of connections
  • use normal Java IO if you're dealing with large transfers to only a handful of hosts/servers
0

精彩评论

暂无评论...
验证码 换一张
取 消