【发布时间】:2015-02-13 18:01:30
【问题描述】:
奇怪的是,有时 BeautifulSoup 对象确实提供了所需的数据,但有时我会收到类似或 listindex error 或 out of range 或 nonetype object does not have attribute findNext() 的错误,这是嵌套在其他元素中的数据。
这是代码:
url = 'http://www.computerstore.nl/product/470130/category-208983/asrock-z97-extreme6.html'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
a = soup.find(text=('Socket')).find_next('dd').string
print(a)
【问题讨论】:
标签: python web-scraping beautifulsoup html-parsing web-crawler