Tuesday, 3 September 2019

Unable to grab tabular contents attached to different participants

I'm trying to get the content of a table related to different participants from a webpage. The information I'm after have been struck through in the image for your understanding. Currently my script can only gives the name of different participants. I wish to parse the information related to those participants as well.

Website Address

As the content are dynamic, I had to use some public API which can be retrieved using dev tools.

The image represents how the information are displayed in that page. Struck through lines are the one I wish to grab.

This is how the API response looks like.

I've tried so far:

import re
import requests

url = 'https://www.bet365.com.au/SportsBook.API/web?'

params = {
    'lid': '30',
    'zid': '0',
    'pd': '#AC#B151#C1#D50#E2#F163#',
    'cid': '13',
    'ctid': '13'
}

r = requests.get(url, params=params,headers={'User-Agent':'Mozilla/5.0'})
games = re.finditer(r'NA=(.*?);', r.text)
for game in games:
    if not 'v' in game.group(): continue
    print(game.group(1))

Output I'm getting are like (partial):

FunPlus Phoenix v Bilibili Gaming
Top Esports v Royal Never Give Up
Moops v Brute
eSuba v eXtatus
CS:GO - V4 Future Sports Festival
PACT v Capri Sun

Output I wish to get like (partial):

26:42    FunPlus Phoenix v Bilibili Gaming    1-1   -      -      21
09:00    Top Esports v Royal Never Give Up     -    2.00   1.72   49
12:00    Moops v Brute                         -    2.10   1.66   17

How can I grab the tabular contents attached to different participants?

PS The information visible here may not be the same in that page as they update every few minutes and I wish to accomplish the task using requests as I've already tried.



from Unable to grab tabular contents attached to different participants

No comments:

Post a Comment