Reputation: 80
Here is a sample link i am scraping: https://www.homedepot.com/p/ZLINE-Kitchen-and-Bath-ZLINE-30-in-Wooden-Wall-Mount-Range-Hood-in-Walnut-Includes-Remote-Motor-KBRR-RS-30/311456581?MERCH=REC-_-rv_gm_pip_rr-_-303727628-_-311456581-_-N
I'm trying to get the internet number and I have tried both css and xpaths
Here's what I've tried
productOMS = product.xpath("//span[@id='product_ID']").getall()
or
productOMS = product.css(".product_internet_number::text").getall()
and here is the html snippet I'm trying to scrape:
<span itemprop="productID" id="product_internet_number" class="" style="" xpath="1">311456581</span>
I also used a xpath selector extension on chrome which gave me
when I use CSS I have a blank field returned and when I use xpath I get something like:
"< span itemprop="productID" id="product_internet_number">312028174"
Any help would be appreciated!
Upvotes: 0
Views: 27
Reputation: 149
try
response.xpath("//span[@id='product_internet_number']/text()").extract()
if you are following up in a sub-selector named product
from response object then:
product.xpath(".//span[@id='product_internet_number']/text()").extract()
Upvotes: 1