360 手机助手爬虫

1.URL分析

打开360 市场的URL,F12 进入到network 模式,分析URL连接:

http://zhushou.360.cn/search/index/?kw=qq

当我点击第二页的时候,查询字符串出现Query String 方法,

多尝试几次,就可以得到URL的连接查询字符串。

2.demo 编写

2.1 请求部分:

  public     String   request(String url) throws IOException {
        CloseableHttpClient httpClient = HttpClients.createDefault();

//        String url = "http://zhushou.360.cn/search/index/?kw=test&page=2";
        System.out.println("URL="+url);
        //创建http request(GET)
        HttpGet request = new HttpGet(url);

        //执行http请求
        CloseableHttpResponse response = httpClient.execute(request);
        //打印response
        String responseStr = EntityUtils.toString(response.getEntity());
//        System.out.println("result="+responseStr);
        return responseStr;
    }

3.运行结果:

3.参考资料:

猜你喜欢

转载自blog.csdn.net/xiamaocheng/article/details/84383130