所以,我想把足球数据从桌子上拿出来,但首先,我想把桌子放在汤里。这就是我的问题所在,我总是得到一个空的列表。你知道吗
代码如下:
import requests
from bs4 import BeautifulSoup
url = 'https://www.eredmenyek.com/foci/nemetorszag/bundesliga/'
oldal = requests.get(url)
soup = BeautifulSoup(oldal.text, "lxml")
review_table_elem = soup.find_all('div', {'class': 'stats-table-container'})
print(review_table_elem)
HTML代码是:
上面有很多人
<div class="stats-table-container"><table id="table-type-1" class="stats-table stats-main table-1" title=""> //And here is the table
硒的一个替代品是requests-html。因为你已经熟悉的要求,你将能够很容易地拿起这个。你知道吗
与之交互的页面在很大程度上依赖javascript来呈现其内容。您要查找的数据不会出现在使用
requests
得到的响应中,因为它不会计算javascript。你知道吗要实现这一点,您将需要使用像seleniumwebdriver这样的东西。下面是一个使用它的解决方案和一个Chrome的无头实例。除了安装
selenium
模块外,您还需要下载ChromeDriver并更改以下代码以将其指向提取到的位置:结果:
相关问题 更多 >
编程相关推荐