simplify, always use json

This commit is contained in:
mwiegand 2023-06-06 12:25:23 +02:00
parent f59a92198e
commit 4f02e83b1a
No known key found for this signature in database

View file

@ -160,26 +160,12 @@ def parse_trs(trs):
# get first page
print('parsing friend messages log')
response = user.session.get('https://help.steampowered.com/en/accountdata/GetFriendMessagesLog')
soup = BeautifulSoup(response.text, 'html.parser')
account_data_table = soup.find(id='AccountDataTable_1')
trs = account_data_table.find_all('tr')[1:]
parse_trs(trs)
# get further pages
continue_value = 1
load_more_button = soup.find(class_='AccountDataLoadMore')
if load_more_button:
continue_value = load_more_button['data-continuevalue']
while True:
print('getting next page')
r = user.session.get(f'https://help.steampowered.com/en/accountdata/AjaxLoadMoreData/?url=GetFriendMessagesLog&continue={continue_value}')
continue_value = r.json()['continue']
if continue_value:
html = r.json()['html']
trs = BeautifulSoup(html, 'html.parser').find_all('tr')
parse_trs(trs)
else:
break
while continue_value:
response = user.session.get(f'https://help.steampowered.com/en/accountdata/AjaxLoadMoreData/?url=GetFriendMessagesLog&continue={continue_value}')
html = response.json()['html']
trs = BeautifulSoup(html, 'html.parser').find_all('tr')
parse_trs(trs)
continue_value = response.json()['continue']