【发布时间】:2017-11-08 23:48:31
【问题描述】:
运行“scrapy crawl word”后,我收到一个错误。我正在尝试使用 Scrapy 来抓取 fda 网站。我正在网上学习教程。这是我的代码:
import scrapy
class WordSpider(scrapy.Spider):
name = "word"
def start_requests(self):
start_url = [
'https://www.fda.gov/Safety/Recalls/'
]
def parse(self, response):
page = response.url
filename = 'www.fda-%s.html' % page
with open(filename, 'wb') as f:
f.write(response.body)
我对代码做了一点改动,因为我只需要一个 url,而“www”对于链接的工作很重要。
我得到的错误是:
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named cryptography.x509'.
我尝试安装 service_identity 但收到同样的错误。不确定我的代码是不正确还是缺少某些包。
【问题讨论】:
标签: python python-3.x web-scraping scrapy