【发布时间】:2020-01-22 16:36:48
【问题描述】:
我正在尝试从该站点获取所有 ID 匹配项。首先,我下载表格以及我将如何为我刚刚下载的所有内容提供打印标签,但是当我尝试获取值 div.id 时,我有 Non; ( 我的意思是这里包含的 ID:
<div class = "event__match event__match - last event__match - oneLine" id = "g_1_ARFva552" title = "Click for match detail!">
如果有人可以帮助我,我该如何下载所有匹配 id ...
这是我的代码:
browser.get("https://www.flashscore.com/football/")
sleep(3)
source = browser.page_source # Get the entire page source from the browser
if browser is not None :browser.close() # No need for the browser so close it
soup = BeautifulSoup(source,'html.parser')
try:
Tags = soup.select('div.leagues--live') # get the elements using css selectors
print(Tags)
for tag in Tags: # loop through them
matchId = tag.find('div').get('id')
print (matchId)
except Exception as e:
print(e)
提前感谢您的帮助
【问题讨论】:
标签: html python-3.x selenium beautifulsoup