2024-06-09 05:50:21 发布
网友
我拿不到绿色数据(
yo = requests.get('http://www.nfl.com/schedules/2019/REG11') soup = bs.BeautifulSoup(yo.text, 'html.parser') table = soup.find('ul', class_="schedules-table") print(table) #correctly gathers all data and extraneous data
绿色突出显示的内容是评论。您可以使用以下代码获取它们:
from bs4 import Comment comments = table.find_all(string=lambda text: isinstance(text, Comment))
它会把他们都列在一张单子上。你可以把它们编码成一个数据帧或者其他你想要的东西
您看到的绿色数据是html中的注释。可以使用bs4中的Comment类获取它-
Comment
from bs4 import BeautifulSoup from bs4 import Comment yo = requests.get('http://www.nfl.com/schedules/2019/REG11') soup = BeautifulSoup(yo.text, 'html.parser') comment = soup.find_all(string=lambda text: isinstance(text, Comment))
会给你所有的评论。你必须自己过滤掉相关的评论
绿色突出显示的内容是评论。您可以使用以下代码获取它们:
它会把他们都列在一张单子上。你可以把它们编码成一个数据帧或者其他你想要的东西
您看到的绿色数据是html中的注释。可以使用bs4中的
Comment
类获取它-会给你所有的评论。你必须自己过滤掉相关的评论
相关问题 更多 >
编程相关推荐