我正在尝试从IPLT20网站上刮擦表格,它不断返回空白[]
from bs4 import BeautifulSoup
import requests
url = 'https://www.iplt20.com/stats/2021/most-runs'
source = requests.get(url)
soup = BeautifulSoup(source.text, 'html.parser')
soup.find_all('table', class_ ='np-mostruns_table')
from bs4 import BeautifulSoup
import requests
url = 'https://www.iplt20.com/stats/2021/most-runs'
source = requests.get(url)
soup = BeautifulSoup(source.text, 'html.parser')
soup.find_all('table', class_ ='np-mostruns_table')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该网站完全是JavaScript,您无法加载JavaScript。
您必须使用自动浏览器,例如
selenium
或类似。我还建议您在刮擦以禁用JavaScript时使用扩展名(像The/Off打开/关)这样的
切换JS
The website is fully javascript, you can't load javascript with requests.
You have to use an automated browser like
selenium
or similar.I also suggest using an extension when you are scraping to disable javascript (toggle on/off) like this
Toggle JS
如果您想找到一个带课堂的表,则应使用:
If you are looking to find a table with class, you should use:
您无法获得该桌子,因为它是动态加载的。您需要找到加载它的查询,并从中构建表。它的字段比网站上显示的要多,因此您可以添加所需的其他字段。我只用网站
输出上的那些字段给出了一个示例:
You can't get the table because it's loaded dynamically. You need to find the query that loads it, and build your table from it. It has many more fields than shown on the site, so you can add additional fields that you need. I gave an example only with those fields that are on the site
OUTPUT: