我遇到了URL应该出现的相同问题http://op1.win007.com/oddslist/1726223.htm
在此处输入图像描述
from selenium import webdriver
from bs4 import BeautifulSoup
url = "http://op1.win007.com/oddslist/1726223.htm"
browser = webdriver.Chrome()
browser.get(url)
soup = BeautifulSoup(browser.page_source, 'html.parser')
containers = soup.findAll("table", {"class": "tcenter"})
print (containers)
打印容器后,显示所有公司和赔率。
如何显示Bet365赔率并将表格输出到excel如下(仅Bet365(
Bet365 3.00 3.40 2.50 32.44 28.63 38.93 97.33 0.96 1.00 0.96
有人能帮我解决这个问题吗?
您在页面上看到的数据是从外部源加载的。这是打印Bet 365
行的脚本:
import re
import json
import requests
url = 'http://1x2d.win007.com/1726223.js'
js_text = requests.get(url).text
game = re.search(r'game=Array((".*"))', js_text).group(1)
data = json.loads('[' + game + ']')
for g in data:
g = g.split('|')
if 'Bet 365' in g:
print(g)
break
打印:
['281', '87788166', 'Bet 365', '2.75', '3.3', '2.5', '34.09', '28.41', '37.5', '93.75', '2.3', '3.4', '3.4', '42.5', '28.75', '28.75', '97.75', '0.92', '0.99', '1.05', '2019,08-1,02,18,45,00', 'bet 365(英国)', '1', '0']