我想从这个页面https://www.betexplorer.com/soccer/estonia/esiliiga/elva-flora-tallinn/Q9KlbwaJ/中获取存档中的最后一个赔率,但我无法通过请求获得它。如果不与Selenium
交互,我如何获得它?
要在开发者工具中触发归档几率页面,我需要将鼠标悬停在奇数上。
代码
url = "https://www.betexplorer.com/archive-odds/4l4ubxv464x0xc78lr/14/"
headers = {
"Referer": "https://www.betexplorer.com",
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36'
}
Json = requests.get(url, headers=headers).json()
由于站点是由JavaScript加载的,
requests
不起作用。我使用selenium
加载页面,在加载所有内容后提取完整的源代码然后使用
beautifulsoup
创建soup
对象以获取所需数据从源代码中可以看到
<tr>
的data-bid
是用来获取odds
数据的我提取了所有的
data-bid
,并将它们一个一个地传递到您在问题末尾提供的URL此代码将以JSON格式获取所有赔率数据
相关问题 更多 >
编程相关推荐