Scrapy response.xpath Invalid Syntax

I am trying to pull pricing information from a website (learning how to build a webcrawler for practice). I am using scrapy to build my crawler and in my prices spider I am attempting to pull the xpath for the html field for prices with the following line of code:

text = response.xpath(‘/html/body/div[8]/div[2]/div[1]/div[2]/div[4]/div[7]/div[1]/div/meta[2]’).extract()

When I run the program I am getting "Syntax Error: Invalid Syntax" with a carrot under the first single quote in response.xpath(). I have tried changing to double quotes which changed nothing. Any ideas?

Upvotes: 1

Views: 766

Answers (1)

Henrique Coura
Henrique Coura

Reputation: 852

It's the type of quotes you are using, use ' or "", not ‘

text = response.xpath('/html/body/div[8]/div[2]/div[1]/div[2]/div[4]/div[7]/div[1]/div/meta[2]').extract()

Upvotes: 2

Related Questions