【发布时间】:2015-09-17 16:30:27
【问题描述】:
我已经使用 pip 安装了 scrapy,并尝试了 scrapy 文档中的示例。
我收到了错误cannot import name xmlrpc_client
在查看 stachoverflow 问题后here 我已经修复了它使用
sudo pip uninstall scrapy
sudo pip install scrapy==0.24.2
但现在它显示给我exceptions.AttributeError: 'HtmlResponse' object has no attribute 'urljoin'
这是我的代码:
import scrapy
class StackOverflowSpider(scrapy.Spider):
name = 'stackoverflow'
start_urls = ['https://stackoverflow.com/questions?sort=votes']
def parse(self, response):
for href in response.css('.question-summary h3 a::attr(href)'):
full_url = response.urljoin(href.extract())
yield scrapy.Request(full_url, callback=self.parse_question)
def parse_question(self, response):
yield {
'title': response.css('h1 a::text').extract()[0],
'votes': response.css('.question .vote-count-post::text').extract()[0],
'body': response.css('.question .post-text').extract()[0],
'tags': response.css('.question .post-tag::text').extract(),
'link': response.url,
}
谁能帮帮我!
【问题讨论】:
标签: python web-scraping scrapy