Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
perf(get_before_data.py): 🐛 修复因 busuanzi 官网一直不返回结果而出现卡死循环的问题。
Browse files Browse the repository at this point in the history
增加验证次数,
大于30次还不返回结果就取0......
  • Loading branch information
zkeq committed May 22, 2022
1 parent 1044213 commit 3586266
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions get_before_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ def get_before_data(host):
'Cookie': 'busuanziId=89D15D1F66D2494F91FB315545BF9C2A'
}
response = None
TIMES = 0
while not response:
response = requests.request("GET", url, headers=headers, data=payload)
print("首次连接,正在从不蒜子官网拉取数据")
if TIMES > 30:
response = 'try{BusuanziCallback_777487655111({"site_uv":0,"page_pv":0,"version":2.4,"site_pv":0});}catch(e){}'
time.sleep(1)
TIMES += 1
str_2_dict = eval(response.text[34:][:-13])
site_uv = str_2_dict["site_uv"]
page_pv = str_2_dict["page_pv"]
Expand Down

0 comments on commit 3586266

Please sign in to comment.