Forbid spider access抓取百度图片失败;

解决方法:

在请求头上加:

        HashMap<String ,String> header=new HashMap<>();
        header.put("Accept-Language","zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
        header.put("Connection","keep-alive");
        header.put("User-Agent","Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0");
        header.put("Upgrade-Insecure-Requests","1");

一般正经的params

        HashMap<String ,Object> params=new HashMap<>();
        params.put("charset", "UTF-8");
        params.put("tn", "resultjson_com");
        params.put("ipn", "rj");
        params.put("ct", "201326592");
        params.put("fp", "result");
        params.put("cl", "2");
        params.put("lm", "-1");//动图
        params.put("ie", "utf-8");
        params.put("oe", "utf-8");
        params.put("st", "-1");
        params.put("ic", "0");
        params.put("istype", "2");
        params.put("qc", "");
        params.put("nc", "1");
        params.put("pn", "0");
        params.put("rn", "10");//每页数量
        params.put("word", "林俊杰");


String respose=OkHttpUtils.okHttpGet( RequestConstants.URL_BAIDU_IMAGE,params,header);

上一篇:maven使用了未经检查或不安全的操作解决方案


下一篇:解决 perl Wide character in print