主函数
package com.company.spriderjd;
import com.company.dao.ProductDao;
import com.company.domain.Product;
import com.google.gson.Gson;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @Author: Ori
* @Date: 2018/8/21
* @Description: version-01
*/
public class JDSprider01 {
private static ProductDao productDao =new ProductDao();
public static void main(String[] args) throws Exception {
/*//1.确定url
String urlStr="https://search.jd.com/Search?keyword=%E6%89%8B%E6%9C%BA&enc=utf-8" +
"&suggest=1.def.0.V01&wq=sh&pvid=4e17067564564bc398d0ffdaba5be084";
//2.获取httpClient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
//3.指定请求方式
HttpGet httpGet = new HttpGet(urlStr);
//4.执行请求,获取响应对象
CloseableHttpResponse response = httpClient.execute(httpGet);
//5.获取HTML页面(获取数据)
String html = EntityUtils.toString(response.getEntity(), "utf-8&