我是新手,我无法弄清楚如何计算时间价值“10:30”。我需要删除一个实时分数门户网站,我已经设法解析了游戏,结果和赔率,但我对时间价值没有好运。我收到这个错误:
AttributeError: 'NoneType' object has no attribute 'time'
我认为这是因为如果我是正确的话,时间不会被宣布为字符串。
我的代码:第一部分:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("headless")
driver = webdriver.Chrome(chrome_options = options)
driver.get('http://www.oddsportal.com/matches/soccer/')
f = open("cote_today.txt", "w")
f.write(driver.page_source.encode("utf-8"))
f.close()
driver.quit()
第二部分:时间功能
from bs4 import BeautifulSoup
f=open("cote_today.txt","r")
soup = BeautifulSoup(f, 'html.parser')
for table_participant in soup.find_all('td', class_='name table-participant'):
print table_participant.get_text()
for result in soup.find_all('td', class_="center bold table-odds table-score"):
print result.get_text()`enter code here`
time_start= soup.find('td', class_="table-time datet t1522666800-1-1-0-0").time
print time_start
答案 0 :(得分:0)
您可以使用.text
<强>实施例强>
time_start= soup.find('td', class_="table-time datet t1522666800-1-1-0-0")
print(time_start.text)