我正在使用beautifulsoup从电子商务网站的产品页面中提取信息。我想要识别的产品页面是:
“CLASS或ID属性中会有‘thumb’单词”,例如:^{cl1}$
目前我的程序只在网址中寻找.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')
损益表
尝试使用regexp模式
相关问题 更多 >
编程相关推荐