我得到的scrapy错误是:
File "/anaconda/lib/python2.7/site-packages/scrapy/http/response/text.py", line 82, in urljoin
return urljoin(get_base_url(self), url)
File "/anaconda/lib/python2.7/urlparse.py", line 261, in urljoin
urlparse(url, bscheme, allow_fragments)
File "/anaconda/lib/python2.7/urlparse.py", line 143, in urlparse
tuple = urlsplit(url, scheme, allow_fragments)
File "/anaconda/lib/python2.7/urlparse.py", line 182, in urlsplit
i = url.find(':')
AttributeError: 'Selector' object has no attribute 'find'
Scrapy在我的蜘蛛中追溯到这一行:
for url in links:
link_url = response.urljoin(url)
这一行是一个通用的parse()方法。我之前已经多次运行完全相同的语法并且从未遇到过错误,并且涉及到urllib的文档和源代码并没有产生任何结果。
任何建议都将不胜感激!
答案 0 :(得分:0)
激活anaconda python 2.7 环境
使用url
或其他技巧检查type()
变量,确保您已正确提取所需的字符串
for url in links:
link_url = response.urljoin(url)
使用python 3.x 而不是python 2.7 ,当scrapy以python 3.x 运行时,错误消息将会出现要清楚易懂。 (这是python36环境中的相同错误)