【发布时间】:2020-06-26 01:20:04
【问题描述】:
我有一个页面的 span 标签
<span itemprop="name">
DeWalt DCD778D2T-GB 18V 2.0Ah Li-Ion XR Brushless Cordless Combi Drill
</span>
如何提取 span 标签内的文本,我尝试使用一些 find 方法但没有收到任何项目对象错误
下面是我试过的代码,我哪里出错了?
r=requests.get('https://www.screwfix.com/p/dewalt-dcd778d2t-gb-18v-2-0ah-li-ion-xr-brushless-cordless-combi-drill/268fx')
c=r.content
soup=BeautifulSoup(c,"html.parser")
ToolName1 = soup.find("span", {"itemprop" : "name"}).text
我的错误是
AttributeError: 'NoneType' 对象没有属性 'text'
【问题讨论】:
标签: python beautifulsoup