【发布时间】:2018-07-19 08:55:11
【问题描述】:
对不起,我对 Selenium 和 python 中的网络抓取非常陌生。我正在尝试抓取超市网站的内容,该网站在 html 中有以下部分
<div class="itemDescription">
<meta itemprop="priceCurrency" content="INR">
<meta itemprop="price" content="23.00">
<h4 class=""><strong class="price js-effective-mrp" data-currency="₹">₹ 23.00 </strong>
<s class="js-actual-mrp" style="display:none;"></s>
<br><a href="/fresh-onion-red-v-1-kg-p.php" class="">Fresh Onion Red <span class="item-quantity">1 Kg</span></a></h4>
</div>
我需要产品的价格、数量和名称。
以下是我编写的代码,但它没有正确解析元素。
div = driver.find_element_by_class_name('itemDescription')
sname =div.find_element_by_css_selector('a').get_attribute('href')
squantity =driver.find_elements_by_class_name('item-quantity')
sprice = driver.find_elements_by_xpath('//*[contains(concat( " ", @class, " " ), concat( " ", "js-effective-mrp", " " ))]')
请帮忙
【问题讨论】:
标签: python selenium selenium-webdriver web-scraping web-crawler