Commit fa1d3fcd authored by 李小芳's avatar 李小芳

add

parent ab0c6648
...@@ -145,33 +145,34 @@ class CrawlerMain(object): ...@@ -145,33 +145,34 @@ class CrawlerMain(object):
def get_services_list(self, res_json, query="", city_name="", city_id=-1): def get_services_list(self, res_json, query="", city_name="", city_id=-1):
page_service_pids = [] page_service_pids = []
current_end_flat = False current_end_flat = False
for service in res_json.get("responseData", {}).get("arr_product", []): if res_json:
current_city = service.get("district_2") for service in res_json.get("responseData", {}).get("arr_product", []):
if int(current_city) == int(city_id): current_city = service.get("district_2")
pid = service.get("pid") if int(current_city) == int(city_id):
spu_id = service.get("spu_id") pid = service.get("pid")
doctor_name = service.get("doctor_name") spu_id = service.get("spu_id")
hospital_name = service.get("hospital_name") doctor_name = service.get("doctor_name")
service_info = self.get_service_base_info(pid) hospital_name = service.get("hospital_name")
service_info['美购id'] = spu_id service_info = self.get_service_base_info(pid)
service_info['sku原价'] = service.get("price_origin") service_info['美购id'] = spu_id
service_info['sku活动价'] = service.get("price_online") service_info['sku原价'] = service.get("price_origin")
service_info['机构等级'] = service.get("avg_score") service_info['sku活动价'] = service.get("price_online")
service_info['美购名称'] = service.get("title") service_info['机构等级'] = service.get("avg_score")
service_info['销量'] = service.get("order_cnt") service_info['美购名称'] = service.get("title")
service_info['skuid'] = pid service_info['销量'] = service.get("order_cnt")
service_info['医生名'] = doctor_name service_info['skuid'] = pid
service_info['医院名称'] = hospital_name service_info['医生名'] = doctor_name
service_info['query词'] = query service_info['医院名称'] = hospital_name
service_info['城市'] = city_name service_info['query词'] = query
service_info['平台'] = "新氧" service_info['城市'] = city_name
service_info['链接'] = "https://y.soyoung.com/cp{}".format(pid) service_info['平台'] = "新氧"
service_info['链接'] = "https://y.soyoung.com/cp{}".format(pid)
sort_service_info = sorted(service_info.items(), key=lambda x: self.title.index(x[0]), reverse=False)
page_service_pids.append(dict(sort_service_info)) sort_service_info = sorted(service_info.items(), key=lambda x: self.title.index(x[0]), reverse=False)
else: page_service_pids.append(dict(sort_service_info))
current_end_flat = True else:
break current_end_flat = True
break
return page_service_pids, current_end_flat return page_service_pids, current_end_flat
def get_service_base_info(self, pid): def get_service_base_info(self, pid):
......
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