我正在尝试关注scrapy.org上的简单教程(http://doc.scrapy.org/en/latest/intro/tutorial.html)
所以我有itemps.py
import scrapy
class DmozItem(scrapy.Item):
title = scrapy.Field()
link = scrapy.Field()
desc = scrapy.Field()
和dmoz_spider.py
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",
"http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"
]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename, 'wb') as f:
f.write(response.body)
But I get this terminal with errors
我使用PowerShell。 Scrapy 1.0.5和Python 2.7.11 | Anaconda 4.0.0(64位)| (默认,2016年2月16日,09:58:36)[MSC v.1500 64位(AMD64)]在win32上
答案 0 :(得分:1)