【发布时间】:2021-11-25 06:31:27
【问题描述】:
from bs4 import BeautifulSoup
import requests
html_text = requests.get('https://www.uplannerperu.com/shop/').text
#print(html_text)
soup = BeautifulSoup(html_text, 'lxml')
archive = soup.find('div', class_ = 'archive-products')
#print(archive)
ulproducts = archive.find_all('ul')
#print(ulproducts)
productname = ulproducts.find()
print(productname)```
This is my print for error code, and somewhere between the begining of the list and the start of the <li class> is something I don't know that is cracking up.
AttributeError Traceback(最近一次调用最后一次) 在 9 ulproducts = archive.find_all('ul') 10 #打印(ulproducts) ---> 11 产品名称 = ulproducts.find('a', href_ = 'https://www.uplannerperu.com/product/botanical-nights-2022/' class="ansi-yellow-intense-fg ansi-bold ">) 12 打印(产品名称)
~\anaconda3\lib\site-packages\bs4\element.py in getattr(self, key) 第2171章 2172 """引发一个有用的异常来解释一个常见的代码修复。""" -> 2173 引发属性错误( 2174 “ResultSet 对象没有属性 '%s'。您可能将元素列表视为单个元素。当您打算调用 find() 时是否调用了 find_all()?” % 钥匙 第2175章
AttributeError:ResultSet 对象没有“find”属性。您可能将元素列表视为单个元素。当你打算调用 find() 时你调用了 find_all() 吗?```
我正在尝试一次抓取所有产品,但我遇到了 HTML 代码解析问题。
【问题讨论】:
标签: python selenium beautifulsoup jupyter-lab