【求助】 python3-scrapy [twisted] CRITICAL: Unhandled error in Deferred
我安装pycharm后用内部terminal可以运行,应该是window shell的问题,希望有懂的大佬分享一下原因,谢谢
2019.4.30
--------------------------------------------------------------------------------------------------------------------------------------------------------------
各位大佬好,小弟在用python3写scrapy框架爬虫时遇到一些问题,代码与问题如下
.\spider\quotes.py
import scrapy
from tutorial.items import QuoteItem
class QuotesSpider(scrapy.Spider):
name = 'quotes'
allowed_domains = ['quotes.toscrape.com']
start_urls = ['http://quotes.toscrape.com/']
def parse(self, response):
item = QuoteItem()
quotes = response.css('.quote')
for quote in quotes:
item['text'] = quote.css('.text::text').extract_first()
item['author'] = quote.css('.author::text').extract_first()
item['tags'] = quote.css('.tags .tag::text').extract()
yield item
next = response.css('.pager .next a::attr("href")').extract_first()
url = response.urljoin(next)
# 内置request函数,需要url, 可选参数callback返回参与的执行函数
yield scrapy.Request(url=url, callback=self.parse)
.\items.py
import scrapy
class QuoteItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
text = scrapy.Field()
author = scrapy.Field()
tags = scrapy.Field()
在输入scrapy crawl quotes后报错页面
1. 操作系统win7 64位,CPU E5-2690, 8G RAM , Anaconda安装Python3.7.3, 相关包全部通过pip安装
2. 尝试重装twisted, scrapy , 用virtualenv, 安装visual C++ 2015 均没有解决。在网上找到stackoverflow有相关问题,点进去页面不存在。。。
之前在家安装没遇到这个问题,现在在公司折腾一下午没解决,恳请各位大佬不吝赐教
2019.4.29