在我运行'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)
我已经改变了一点代码,因为我只需要一个网址,而'www'对于链接起作用非常重要。
我得到的错误是:
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named cryptography.x509'.
我尝试安装service_identity但我收到了同样的错误。不确定我的代码是不正确还是我错过了一些包。
好像你缺少一些TLS包,我建议安装加密和OpenSSL包。
pip install cryptography
OpenSSL的:
brew install openssl