折腾阿,请求大家帮助 httpclient的 -凯发k8国际

0 0

折腾阿,请求大家帮助 httpclient的10

是这样的,用httpclient4.3 访问网址。

http://weblbs.yystatic.com//get-data/84166046?subsid=2352881662&type=yyscene&_=47338133

总是返回404错误,但是网页访问肯定是没问题的。为什么httpclient总是不对呢?是不是和"//"有关系。

折腾了一天了。其他的都ok的。

按照浏览器的请求模式,严格按照抓包的来做的。但是总是404.
2015年1月16日 01:41

3个答案

0 0

百度 google

2016年8月22日 15:41
0 0

你一定要用httpclient,进行抓取数据吗?如果不用,那我提供你个方法吧。
public static string getcontentby{
    stringbuffer document= null;
    url targeturl;
    int time=1;
    while(time==1){
    time--;

    try {
        targeturl = new ;
        httpurlconnection con = (httpurlconnection) targeturl.openconnection();
       
        con.setfollowredirects(true);
        con.setconnecttimeout(200000);
        con.setreadtimeout(200000);
        con.setinstancefollowredirects(false);
        con.connect();
        bufferedreader br = new bufferedreader(new inputstreamreader(con.getinputstream(),ecode));
        string s = "";
        document= new stringbuffer();
        while ((s = br.readline()) != null) {
            document.append(s);
        }
        s=null;
        br.close();
        return document.tostring();
       
    } catch (malformedurlexception e) {
        // todo auto-generated catch block
    time ;
    } catch (ioexception e) {
    time ;
        // todo auto-generated catch block
    }
    }
    return "";
   
}

2015年1月19日 17:14
0 0

因为httpclient自动把//get-data变成/get-data了,双斜杠变成单斜杠,所以总是404,抓包看一下便知

2015年1月16日 11:39

相关推荐

    httpclient 请求两种方式,如果有cookie可加上cookies,同步获取返回值

    try(closeablehttpclient httpclient = httpclients.createdefault()) { httppost httppost = new httppost(url); stringentity stringentity = new stringentity(params, charset.forname("utf-8")); ...

    httpurlconnection请求和httpclient请求...................................................................

    详细说明在https://blog.csdn.net/zyf2533/article/details/118294101?spm=1001.2014.3001.5501

    httpclient,发送异步请求,get、post请求

    http请求工具类httpclientutil,get,post请求(csdn)————程序

    不会的可以在评论区留言哈,这是我自己做项目用到的。所以绝对可用!同时共享出来给到大家

    php中http请求封装httpclient精华中的经典代码。从国外凯发k8国际娱乐官网入口官网直接下的,看看人家怎么封装的,受益匪浅啊,堪称经典。里边有说明和实例

    利用httpclient发送http请求 利用httpclient发送http请求

    其中包含项目post-demo定义接口;包含另一个项目httpclient-demo使用工具类发送post请求调用接口。详细内容查看博客 httpclient发送post请求

    java httpclient 发送get请求和带有表单参数的post请求教程例子

    angular中的数据请求 内置模块httpclient实现(get post jsonp 以及第三方模板axios请求数据(32分12秒)

    httpclient的用法,发送get请求和post请求,设置header

    http请求工具类-httpclientutils 还需要httpclientresult类

    httpclient请求(get请求、post请求)

    httpclient post方式发送json格式数据,需要的相关包。

    httpclient与asynctask与服务器的结合使用

    null 博文链接:https://javasam.iteye.com/blog/2117845

    angular中的数据请求 内置模块httpclient实现(get post jsonp 以及第三方模板axios请求数据示例代码.zip

    c# httpclienthelper(httpclient工具类) 包含 同步/异步请求 返回 string/泛型类型/xml 及一个单例模式 的 singlehelper 适合做爬虫

global site tag (gtag.js) - google analytics
网站地图