【发布时间】:2020-01-12 10:02:21
【问题描述】:
我正在学习/进行网络抓取并遇到一个问题,我有一个 bs4.element.ResultSet 类型的对象
其中包含一些 div 标签,我想像在bs4.BeautifulSoup 类型对象中那样提取它
我想要突出显示的代码
原来如此
from bs4 import BeautifulSoup
import requests
url = 'https://www.simplilearn.com/resources'
result = requests.get(url)
web_page = result.content
soup = BeautifulSoup(web_page, 'html.parser')
article = soup.findAll(class_='contentBySegment') #that gives me bs4.element.ResultSet
然后,我尝试使用 find 方法,但它不起作用,而是出现错误。 我的目标是获取文章主题名称 可以在该代码的这一部分中看到
那么,我该怎么办
【问题讨论】:
-
请发布可重现的示例和代码。
标签: python beautifulsoup tags