我对python很陌生,我想用scrapy来构建一个网络爬虫。我阅读了http://blog.siliconstraits.vn/building-web-crawler-scrapy/的教程。蜘蛛代码如下所示:
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from nettuts.items import NettutsItem
from scrapy.http import Request
class MySpider(BaseSpider):
name = "nettuts"
allowed_domains = ["net.tutsplus.com"]
start_urls = ["http://net.tutsplus.com/"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
titles = hxs.select('//h1[@class="post_title"]/a/text()').extract()
for title in titles:
item = NettutsItem()
item["title"] = title
yield item当使用命令行: scrapy爬行nettus启动蜘蛛时,它有以下错误:
[boto] DEBUG: Retrieving credentials from metadata server.
2015-07-05 18:27:17 [boto] ERROR: Caught exception reading instance data
Traceback (most recent call last):
File "/anaconda/lib/python2.7/site-packages/boto/utils.py", line 210, in retry_url
r = opener.open(req, timeout=timeout)
File "/anaconda/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/anaconda/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/anaconda/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/anaconda/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/anaconda/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 65] No route to host>
2015-07-05 18:27:17 [boto] ERROR: Unable to read instance data, giving up真的不知道怎么回事。希望有人能帮忙
发布于 2015-07-05 18:24:32
在settings.py文件中:添加以下代码设置:
DOWNLOAD_HANDLERS = {'s3':无,}
发布于 2015-07-05 16:49:23
重要的信息是:
URLError: <urlopen error [Errno 65] No route to host>这是想告诉你,你的电脑不知道如何与你想刮的网站沟通。您是否能够正常地(即在web浏览器中)从运行此python的机器上访问该站点?
https://stackoverflow.com/questions/31232681
复制相似问题