Commit 7e3262e5 authored by litianle's avatar litianle

添加711

parent 074bac95
......@@ -20,7 +20,7 @@ public class FamilyMartCrawler {
private static final String SK_NAME = "全家";
private static final String URL = "http://www.familymart.com.cn/store";
private static final Map<String, String> citys = new LinkedHashMap<>();
private static final Map<String, String> city = new LinkedHashMap<>();
/**
* /store/Search?cid=1&page=1 POST请求
......@@ -46,10 +46,10 @@ public class FamilyMartCrawler {
String html = elements.html();
Elements options = Jsoup.parse(html).getElementsByTag("option");
for (Element option : options) {
citys.put(option.text(), option.val());
city.put(option.text(), option.val());
}
citys.forEach((cityName, cid) -> {
city.forEach((cityName, cid) -> {
String station = HttpUtil.createPost("http://www.familymart.com.cn/store/Search")
.form("cid", cid)
.form("aid")
......@@ -61,8 +61,10 @@ public class FamilyMartCrawler {
.execute().body();
List<Store> stores = new JSONObject(station).getJSONArray("mapmsg").toList(Store.class);
stores.forEach(e -> {
CrawlerStore crawlerStore = new CrawlerStore().setCrawlerUrl(URL)
.setSkName(SK_NAME).setPhone(e.getTelphone())
CrawlerStore crawlerStore = new CrawlerStore()
.setCrawlerUrl(URL)
.setSkName(SK_NAME)
.setPhone(e.getTelphone())
.setType(cityName)
.setName(e.getName())
.setAddress(e.getStreet())
......
package com.deeprec.crawler.modules.seven_Eleven.crawler;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.deeprec.crawler.entry.CrawlerStore;
import com.deeprec.crawler.mapper.InsertDB;
import com.deeprec.crawler.modules.seven_Eleven.dto.Store;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class SevenElevenCrawler {
private static final String SK_NAME = "7-11";
private static final String URL = "http://www.7-11cd.cn/shop/nearShop.aspx";
static List<String> insertedList = new ArrayList<>();
public static void main(String[] args) {
// 网站上目前只有成都的cityID
for (int cityId = 1000; cityId <= 9999; cityId++) {
String response = HttpUtil.createPost("http://www.7-11cd.cn/AJAX/shop.ashx")
.form("action", "getList")
.form("cityID", cityId)
.execute().body();
List<Store> stores = new JSONArray(response).toList(Store.class);
log.info("查询到" + cityId + stores);
if (stores.size() == 0) continue;
for (Store store : stores) {
if (insertedList.contains(store.getId()))
continue;
insertedList.add(store.getId());
CrawlerStore crawlerStore = new CrawlerStore().setCrawlerUrl(URL)
.setSkName(SK_NAME)
.setPhone(store.getPhone())
.setName(store.getShopName())
.setAddress(store.getAddress())
.setExtInfo(new JSONObject()
.set("openDate", store.getOpenDate())
.set("cityFullName", store.getCityFullName()));
// InsertDB.getDB().insert(crawlerStore);
log.info("区域: {},{}", crawlerStore.getAddress(), crawlerStore);
}
}
log.info("7-11便利店全部插入完成");
}
}
package com.deeprec.crawler.modules.seven_Eleven.dto;
import lombok.Data;
@Data
public class Store {
String id;
String address;
String cityFullName;
String shopName;
String bMap_lat;
String bMap_lng;
String phone;
String openDate;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment