Commit 5f2ac9ce authored by 李小芳's avatar 李小芳

update

parent 4309e098
......@@ -111,7 +111,6 @@ class SoYoung(object):
def search(self, page=0):
try:
# 每次请求之前先暂停几秒 防止被ban
s = random.random()
time.sleep(s)
self.headers["page"] = page
......@@ -120,6 +119,7 @@ class SoYoung(object):
response = json.loads(response_res.text)
return response
elif response_res.status_code == 403:
time.sleep(30)
return self.search()
else:
print("列表请求发生错误,停止请求")
......@@ -201,7 +201,6 @@ class SoYoung(object):
return {}, {}
if __name__ == '__main__':
soyoung = SoYoung()
hospital_red_bag = {}
......@@ -213,17 +212,18 @@ if __name__ == '__main__':
print(all_hospital_shangwu_info)
# f = open("医院尾款劵数据.csv", "a+", encoding="utf-8")
# csv_writer = csv.writer(f)
# # csv_writer.writerow(
# # ["大区", "城市", "商务", "机构名称", "满", "减", "劣势/缺失", "到期时间", "查到劣势日期", "最晚补券时间"])
#
# for i in range(1, 2):
# hospital_red_bag, city_info = soyoung.response_analysis(page=i, have_get_hospital_id=have_get_hospital_id)
# for name, value in hospital_red_bag.items():
# for item in value:
# csv_writer.writerow(["", city_info[name], "", name, item.get("红包满减"), item.get("红包金额"), "",
# item.get("到期时间"),
# time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), ""])
# print("have_get_hospital_id:", have_get_hospital_id)
# print(hospital_red_bag)
f = open("医院尾款劵数据.csv", "a+", encoding="utf-8")
csv_writer = csv.writer(f)
# csv_writer.writerow(
# ["大区", "城市", "商务", "机构名称", "满", "减", "劣势/缺失", "到期时间", "查到劣势日期", "最晚补券时间"])
#page
for i in range(1, 2):
hospital_red_bag, city_info = soyoung.response_analysis(page=i, have_get_hospital_id=have_get_hospital_id)
for name, value in hospital_red_bag.items():
for item in value:
csv_writer.writerow(["", city_info[name], "", name, item.get("红包满减"), item.get("红包金额"), "",
item.get("到期时间"),
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), ""])
print("have_get_hospital_id:", have_get_hospital_id)
print(hospital_red_bag)
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