Reputation: 43
It shows me error in this line:
name = sel.xpath("//*[@class = "inline t-24 t-black t-normal break-words"]/text()").extract_first().split()
Error:
File "<ipython-input-9-f8d78586cc1a>", line 7
name = sel.xpath("//*[@class = "inline t-24 t-black t-normal break-words"]/text()").extract_first().split()
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 160
Reputation: 1649
Try this instead:
name = sel.xpath('//*[@class = "inline t-24 t-black t-normal break-words"]/text()1).extract_first().split()
More generally speaking, you may define strings in python using single quotes or double quotes:
str1 = "hi there"
str2 = 'goodbye'
However, if you with to define a string with single / double quotes inside, you need to use the other kind outside for string definition:
str3 = "he said: `I quote with single quotes`"
str4 = 'she said: "I quote with double quotes"'
print(str3) # yields he said: `I quote with single quotes`
print(str4) # yields she said: "I quote with double quotes"
You need to alternate single and double quotes for the string to remain consistent.
Upvotes: 2