【发布时间】:2014-07-30 07:52:29
【问题描述】:
我正在使用 beautifulsoup 从电子商务网站的产品页面中提取信息。我要识别的产品页面是:
"CLASS 或 ID 属性中将包含 'thumb' 字样" 例如:class="product_thumbs" id = "thumbimages" 等
目前我的程序仅在 URL 中查找 .html,但这仅适用于一个电子商务网站。但我希望它搜索整个 html 并查找其中包含“thumb”字样的 ID 和 CLASS 属性。
我目前的代码如下:
if ".html" in childurl: # store details into product_details table if its a product page
print("Product Found.!")
print(childurl)
soup = BeautifulSoup(urllib2.urlopen(childurl).read())
priceele = soup.find(itemprop='price').string.strip()
brandname = soup.find(itemprop='brand').string.strip()
nameele = soup.find(itemprop='name').string.strip()
image = soup.find(itemprop='image').get('src')
请
【问题讨论】:
标签: python beautifulsoup web-crawler