不要使用findAll()

时间:2019-04-02 13:47:28

标签: python

我一直试图在以下网站上找到所有游戏ID:https://www.flashscore.com/football/germany/bundesliga/results

我想获取所有格式为g_1_nXU7hYul的ID:

<tr id="g_1_nXU7hYul" class="odd stage-finished" style="cursor: pointer;">
    <td class="cell_ib icons left"></td>
    <td class="cell_ad time">31.03. 18:00</td>
    <td class="cell_ab team-home  bold" title="Click for match detail!">
        <span class="padr">Eintracht Frankfurt</span>
    </td>
    <td class="cell_ac team-away">
        <span class="padl">Stuttgart</span>
    </td>
    <td class="cell_sa score  bold">3&nbsp;:&nbsp;0</td>
    <td class="cell_ia icons">
        <span class="icons"></span>
    </td>
</tr>

我尝试了下面的代码,但是输出是错误的。

from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

my_url = "https://www.flashscore.com/football/germany/bundesliga/results/"

uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")

containers = page_soup.findAll("tr", {"class":"odd stage-finished"})
print(containers[0])

我希望所有tr节点,但找不到任何节点

0 个答案:

没有答案