mirror of
https://github.com/LibraHp/GetQzonehistory.git
synced 2025-02-23 14:09:07 +00:00
修复获取说说时中途退出的bug
This commit is contained in:
parent
38a4b95ed1
commit
9b56f514cf
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/resource/
|
||||||
|
.idea
|
||||||
|
/myenv/
|
25
main.py
25
main.py
@ -239,11 +239,23 @@ def get_message(start, count):
|
|||||||
g_tk,
|
g_tk,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
response = requests.get('https://user.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/feeds2_html_pav_all',
|
|
||||||
params=params, cookies=cookies, headers=headers)
|
try:
|
||||||
|
response = requests.get(
|
||||||
|
'https://user.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/feeds2_html_pav_all',
|
||||||
|
params=params,
|
||||||
|
cookies=cookies,
|
||||||
|
headers=headers,
|
||||||
|
timeout=(5, 10) # 设置连接超时为5秒,读取超时为10秒
|
||||||
|
)
|
||||||
|
except requests.Timeout:
|
||||||
|
print("请求超时")
|
||||||
|
return None
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_login_user_info():
|
def get_login_user_info():
|
||||||
response = requests.get('https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=' + str(g_tk) + '&uins=' + uin,
|
response = requests.get('https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=' + str(g_tk) + '&uins=' + uin,
|
||||||
headers=headers, cookies=cookies)
|
headers=headers, cookies=cookies)
|
||||||
@ -319,20 +331,21 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
for i in trange(int(count / 100) + 1, desc='Progress', unit='100条'):
|
for i in trange(int(count / 100) + 1, desc='Progress', unit='100条'):
|
||||||
message = get_message(i * 100, 100).content.decode('utf-8')
|
message = get_message(i * 100, 100).content.decode('utf-8')
|
||||||
|
time.sleep(0.2)
|
||||||
html = process_old_html(message)
|
html = process_old_html(message)
|
||||||
if "li" not in html:
|
if "li" not in html:
|
||||||
break
|
continue
|
||||||
soup = BeautifulSoup(html, 'html.parser')
|
soup = BeautifulSoup(html, 'html.parser')
|
||||||
for element in soup.find_all('li', class_='f-single f-s-s'):
|
for element in soup.find_all('li', class_='f-single f-s-s'):
|
||||||
time = None
|
put_time = None
|
||||||
text = None
|
text = None
|
||||||
time_element = element.find('div', class_='info-detail')
|
time_element = element.find('div', class_='info-detail')
|
||||||
text_element = element.find('p', class_='txt-box-title ellipsis-one')
|
text_element = element.find('p', class_='txt-box-title ellipsis-one')
|
||||||
if time_element is not None and text_element is not None:
|
if time_element is not None and text_element is not None:
|
||||||
time = time_element.get_text().replace('\xa0', ' ')
|
put_time = time_element.get_text().replace('\xa0', ' ')
|
||||||
text = text_element.get_text().replace('\xa0', ' ')
|
text = text_element.get_text().replace('\xa0', ' ')
|
||||||
if text not in [sublist[1] for sublist in texts]:
|
if text not in [sublist[1] for sublist in texts]:
|
||||||
texts.append([time, text])
|
texts.append([put_time, text])
|
||||||
|
|
||||||
if len(texts) > 0:
|
if len(texts) > 0:
|
||||||
save_data()
|
save_data()
|
||||||
|
Loading…
Reference in New Issue
Block a user