【发布时间】:2021-06-14 22:31:31
【问题描述】:
我想从以下网站阅读价格。 但是当我运行时,我得到了 [TypeError: object of type 'NoneType' has no len()] 错误。
word = '0735850859699'
driver = webdriver.Chrome('chromedriver.exe')
url = driver.get("https://www.lotteon.com/p/product/LM" + str(word))
time.sleep(3)
soup = BeautifulSoup(url, 'lxml')
content = soup.findAll("div", {"class":"price"}).text
print(content)
【问题讨论】:
-
findAll 返回一个没有 .text 属性的列表。
-
你能给我们完整的错误文本吗?
-
完全错误:回溯(最近一次调用最后一次):文件“c:\0_MINSU\PythonWorksapce\practice.py”,第 165 行,在
汤 = BeautifulSoup(url, 'lxml') init 中的文件“C:\Users\lemi7005\AppData\Local\Programs\Python\Python39\lib\site-packages\bs4_init_.py”,第 310 行elif len(markup)
标签: python