您现在的位置: 爱51代码网 >> 范文 >> 文章正文
client.executeMethod(httppost卡住不动

client.executeMethod(httppost卡住不动

写了个 httpclient post 的爬虫,

header部分全部模仿ie

循环的时候会卡住不动,(对单网站循环)

也不超时也不出错,像是假死了一样,很诡异

貌似问题出在 client.executeMethod(httppost); 这行,

不知道具体哪里的问题,有人遇到过这种情况么

               System.setProperty( "org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog" ); //关闭日志                                 Protocol authhttps = new Protocol("https",                                 new AuthSSLProtocolSocketFactory( new URL("file:my.keystore"), "123456",                                 new URL("file:my.truststore"), "123456"),                                 443);                           HttpClient client = new HttpClient();                         client.getHttpConnectionManager().getParams().setConnectionTimeout(3000);                         client.getHttpConnectionManager().getParams().setSoTimeout(3000);                                   client.getHostConfiguration().setHost("target-com", 443, authhttps);                                                   /* 只能使用相对路径 */                        GetMethod httpget = new GetMethod("/link");                         client.executeMethod(httpget);                         PostMethod httppost=new PostMethod("https-://target-com");                                 httppost.setRequestHeader("Referer", "https-://target-com");                         httppost.setRequestHeader("Accept-Language", "en-US");                         httppost.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                         httppost.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0)");                         //httppost.setRequestHeader("Connection", "Keep-Alive");                         //httppost.setRequestHeader("Cache-Control", "no-cache");                                                 httppost.setParameter("id", id);                         httppost.setParameter("link", link);                         httppost.setParameter("tb", "e1s1");                         httppost.setParameter("_eventId", "submit");                         client.executeMethod(httppost);                                   String result = new String(httppost.getResponseBody());                         httpget.releaseConnection(); //关闭连接                         httppost.releaseConnection(); //关闭连接     }

加上循环,跑着跑着就停住不动了,跟假死一样,内存也不见变化,

上面那2个超时设置都不管用,一直卡住不动,都不会超时

  • 上一篇文章:

  • 下一篇文章: 没有了
  • 最新文章 热点文章 相关文章
    GIS用百度行政区域的经纬度直接画
    不小心卸载了.net 4 extend,vs2
    C#byte【】里的数转换成string时
    C#的session取不到值
    java如何判断一个字符串里的数字
    随机找出24个不一样的字,在把一
    java怎么实现html转为pdf
    lotus数据列表文档个数如何实时统
    lotus代理中LS如何将字符串保存到
    在lotus BS系统里怎样方便实现统
    不小心卸载了.net 4 extend,vs2
    C#的session取不到值
    java如何判断一个字符串里的数字
    java怎么实现html转为pdf
    undefined reference timer_crea
    linux文件/usr/lib破坏了,还原后
    Failed to open eth0
    android手机无法与eclipse或电脑
    C/C++洗牌算法源代码
    ZOJ 3700 Ever Dream 文章中单词
    The APR based Apache Tomca
    tabPanel嵌套内部panel 内部
    failed to lazily initializ
    SSH框架在页面表单中的数据上
    ,<s:submit>怎么样做表单验
    Eclipse中怎样调试JSP页面
    java如何判断一个字符串里的
    随机找出24个不一样的字,在
    java怎么实现html转为pdf
    tomcat用debug启动不了用ser
     



    设为首页 | 加入收藏 | 网站地图 | 友情链接 |