我是初学者。我不知道我的代码的哪一部分出错了。 另外,如何将内容和作者同时写入文件?谢谢!
class QuoteSpider(scrapy.Spider):
name = "quote"
start_url = [
'http://quotes.toscrape.com/tag/humor/',
]
def parse(self, response):
filename = 'quotes-humor.html'
Cont = response.css('span.text::text').extract()
#Author = response.css('span.author::text').extract()
with open(filename, 'wb') as f:
f.write(Cont)
self.log('Saved file %s' % filename)