我正在尝试从https://sunshinetour.com/stats/抓取数据,但是,如果我尝试访问定位标记,它将返回一个变量而不是实际值。这是我的代码:
pager.page = 3 // NEW VALUE
这是我得到的结果:
from bs4 import BeautifulSoup
import requests
page = requests.get('https://sunshinetour.com/stats/')
soup = BeautifulSoup(page.text, 'html.parser')
for player in soup.find_all('a', class_='player-name-table'):
print(player.text)
谢谢您的帮助
答案 0 :(得分:0)
如果要在该页面上抓取表格,请调用以下api(返回json)
page = requests.get('https://sunshinetour.com/api/sst/cache/sst/219S/219S-ooms-oom-FT.json?randomadd=1575877373100')
for item in page.json().get('oom').get('oom_entry'):
print(item.get('name'),'\t',
item.get('nationality'),'\t',
item.get('oom_value'),'\t',
item.get('tournaments_played'))
Daniel van Tonder RSA 1,511,262.56 13
Branden Grace RSA 1,332,272.40 1
Charl Schwartzel RSA 1,332,272.40 1
MJ Viljoen RSA 825,268.65 16
Jaco Ahlers RSA 773,652.24 13
Thriston Lawrence RSA 739,455.53 14
JC Ritchie RSA 665,548.53 11
......