From f745492d81dd66118372068f8006259083683f17 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Wed, 20 Jul 2022 16:45:20 +0800 Subject: [PATCH] update --- .../avgprice/ExportNearestAvgPrice.groovy | 4 +- .../script/gj/crawl/AnjukeDistSearch.groovy | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeDistSearch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/avgprice/ExportNearestAvgPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/avgprice/ExportNearestAvgPrice.groovy index 62b08004f..4d1847be2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/avgprice/ExportNearestAvgPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/avgprice/ExportNearestAvgPrice.groovy @@ -29,9 +29,9 @@ public class ExportNearestAvgPrice { static main(args) { - def citys = ["苏州"]//findAllCity(); + def citys = ["重庆"]//findAllCity(); def task = new ExportNearestAvgPrice(); - def weekends = task.findWeekends(34);//日期最近的X期 + def weekends = task.findWeekends(12);//日期最近的X期 // task.exportAllCity(citys, weekends, "e:\\全国城市均价.csv"); task.exportRegion(citys, weekends, "D:\\数据\\区域均价.csv"); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeDistSearch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeDistSearch.groovy new file mode 100644 index 000000000..afa1280a4 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/crawl/AnjukeDistSearch.groovy @@ -0,0 +1,39 @@ +package com.fangjia.script.gj.crawl + +import com.fangjia.script.util.ABuYunUtil +import com.fangjia.script.util.ExcelUtils +import net.sf.json.JSONObject + +class AnjukeDistSearch { + static main(args) { + def task = new AnjukeDistSearch() + task.run() + } + + def run(){ + def file = "D:\\数据\\朔州匹配房源1.xlsx" + ExcelUtils.modify(file,{d-> + def data = getDataInfo(282, d['C']) + if(data){ + def match = data.match + if(match){ + println match + } + } + }) + getDataInfo() + } + + def getDataInfo(cityId, keyword){ + def url = "https://m.anjuke.com/ajax/autocomplete/?city_id=282&kw="+URLEncoder.encode(keyword, "utf-8") + def ret = ABuYunUtil.doGet(url, null, null, "utf-8") + if (ret) { + JSONObject jsonObj = JSONObject.fromObject(ret); + if (jsonObj && jsonObj.msg == "ok") { + def data = jsonObj.data + return data + } + } + return null + } +}