网站来源显示:
<div class="content">
<h2 class="branded">Fixtures</h2>
<div class="mobile-select gameweek-selector-div clearfix">
<select class="gameweek-selector" >
<option value="-1">All Season</option>
<option value="1">Matchweek 1</option>
<option value="2">Matchweek 2</option>
<option value="3">Matchweek 3</option>
</select>
</div>
我想在选择其中一个选项值时抓取数据 问题是网站网址没有改变它只是加载内容
答案 0 :(得分:1)
尝试使用浏览器的网络分析仪。
当我访问该网站并选择不同的匹配周时,每次都会发送一个GET请求。
例如,以下是第1周的请求网址:
http://m.premierleague.com/pa-services/api/football/mobile/competition/fandr/api/gameweek/1.json
......第2周:
http://m.premierleague.com/pa-services/api/football/mobile/competition/fandr/api/gameweek/2.json
注意最后的数字是所有改变的。您可以轻松地遍历您的周范围,在每次迭代时发出GET请求。
以下是解决方案的草图:
import json
import urllib
number_of_weeks = 20
base_url = 'http://m.premierleague.com/pa-services/api/football/mobile/competition/fandr/api/gameweek/'
for i in range(1, number_of_weeks+1):
page = urllib.urlopen(baseurl+str(i)).read()
json_content = json.loads(page)
## now you can do something with the data
答案 1 :(得分:0)