simplify, always use json
This commit is contained in:
parent
f59a92198e
commit
4f02e83b1a
1 changed files with 7 additions and 21 deletions
|
@ -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']
|
||||
|
|
Loading…
Reference in a new issue