Home > Enterprise >  Trouble scraping Div class with same class Ids with Xpath
Trouble scraping Div class with same class Ids with Xpath

Time:12-17

I'm trying to scrape the Body style but having trouble pulling it

https://www.maplesford.com/new-Warsaw-2022-Ford-Escape-SEL-1FMCU9H97NUB34573

body_style = response.xpath(".//div[@class='vdp-info-media vdp-body-style']/text()").get()

My issue is I can't seem to drop the levels down to pull the body style. stuck at /text() don't know how to pull the body style.

CodePudding user response:

You're looking for:

body_style = response.xpath("//li[@class='vdp-info media vdp-body-style']//h3/text()").get()

Check Scrapy docs here

  • Related