Here is my code
这是我的代码
import scrapy
class spider1(scrapy.Spider):
name= 'Wikiipedia'
start_urls = ['https://en.wikipedia.org/wiki/Battery_(electricity)']
def parsed(self, response):
print response.css("h1#firstHeading::text").extract()
When executed in command prompt it shows the following error
在命令提示符下执行时,它显示以下错误
print response.css("h1#firstHeading::text").extract()
^
SyntaxError: invalid syntax
I don't know what i did wrong. Can anyone help me with this one?
我不知道我做错了什么。任何人都可以帮我这个吗?
2 个解决方案
#1
0
I tried your codes it worked fine. (i think it should be 'parse' but not 'parsed')
我尝试了你的代码,它工作得很好。 (我认为它应该是'解析'但不是'解析')
#2
0
Just pointing out that Stack was correct in my case. Python 3 requires you to use parentheses with the print statement and everything works fine then.
只是指出Stack在我的情况下是正确的。 Python 3要求你使用带有print语句的括号,然后一切正常。
#1
0
I tried your codes it worked fine. (i think it should be 'parse' but not 'parsed')
我尝试了你的代码,它工作得很好。 (我认为它应该是'解析'但不是'解析')
#2
0
Just pointing out that Stack was correct in my case. Python 3 requires you to use parentheses with the print statement and everything works fine then.
只是指出Stack在我的情况下是正确的。 Python 3要求你使用带有print语句的括号,然后一切正常。