【发布时间】:2017-09-02 07:58:33
【问题描述】:
我正在尝试解析 this website 并使用 BeautifulSoup.find 在内容框 card__body 中获取有关 auto 的信息,但它没有找到所有类。我也试过webdriver.PhantomJS(),但也没有显示。
这是我的代码:
from bs4 import BeautifulSoup
from selenium import webdriver
url='http://www.autobody.ru/catalog/10230/217881/'
browser = webdriver.PhantomJS()
browser.get(url)
html = browser.page_source
soup = BeautifulSoup(html, 'html5lib')
JTitems = soup.find("div", attrs={"class":"content-box__strong red-text card__price"})
JTitems
或
w = soup.find("div", attrs={"class":"content-box card__body"})
w
为什么这种方法不起作用?我应该怎么做才能获得有关汽车的所有信息?我正在使用 Python 2.7。
【问题讨论】:
-
你确定这些元素在页面中,有这些特定的类吗?
-
在问题中包含一些标记。
-
网站中没有
content-box card__body类的元素,如果您可以包含您想要提取的确切文本,它将对每个试图提供帮助的人有所帮助。 -
我正在尝试提取此文本 - 2208р(红色)和下面的所有内容
标签: python parsing beautifulsoup