运行scrapy shell 'http://quotes.toscrape.com'出现错误ValueError: invalid hostname: 'http

运行scrapy shell r’http://quotes.toscrape.com‘出现错误ValueError: invalid hostname: r’http

我在学习python的scrapy框架时,在windows10下面运行cmd后,在命令行里输入scrapy shell ‘http://quotes.toscrape.com‘命令时报错ValueError: invalid hostname: ‘http
详细的错误如下:

2017-05-20 12:13:47 [scrapy.utils.log] INFO: Scrapy 1.3.3 started (bot: scrapybot)
2017-05-20 12:13:47 [scrapy.utils.log] INFO: Overridden settings: {'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter', 'LOGSTATS_INTERVAL': 0}
2017-05-20 12:13:47 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
 'scrapy.extensions.telnet.TelnetConsole']
2017-05-20 12:13:47 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
 'scrapy.downloadermiddlewares.retry.RetryMiddleware',
 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',                                                          'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
 'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
 'scrapy.downloadermiddlewares.stats.DownloaderStats']
2017-05-20 12:13:47 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
 'scrapy.spidermiddlewares.referer.RefererMiddleware',
 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
 'scrapy.spidermiddlewares.depth.DepthMiddleware']
2017-05-20 12:13:47 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2017-05-20 12:13:47 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-05-20 12:13:47 [scrapy.core.engine] INFO: Spider opened
Traceback (most recent call last):
  File "I:\Anaconda3\Scripts\scrapy-script.py", line 5, in 
    sys.exit(scrapy.cmdline.execute())
  File "I:\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 142, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "I:\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 88, in _run_print_help
    func(*a, **kw)
  File "I:\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 149, in _run_command
    cmd.run(args, opts)
  File "I:\Anaconda3\lib\site-packages\scrapy\commands\shell.py", line 73, in run
    shell.start(url=url, redirect=not opts.no_redirect)
  File "I:\Anaconda3\lib\site-packages\scrapy\shell.py", line 48, in start
    self.fetch(url, spider, redirect=redirect)
  File "I:\Anaconda3\lib\site-packages\scrapy\shell.py", line 115, in fetch
    reactor, self._schedule, request, spider)
  File "I:\Anaconda3\lib\site-packages\twisted\internet\threads.py", line 122, in blockingCallFromThread
    result.raiseException()
  File "I:\Anaconda3\lib\site-packages\twisted\python\failure.py", line 372, in raiseException
    raise self.value.with_traceback(self.tb)
ValueError: invalid hostname: 'http

C:\Users\JempJohnson>scrapy shell r'http://quotes.toscrape.com'
2017-05-20 12:18:56 [scrapy.utils.log] INFO: Scrapy 1.3.3 started (bot: scrapybot)
2017-05-20 12:18:56 [scrapy.utils.log] INFO: Overridden settings: {'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter', 'LOGSTATS_INTERVAL': 0}
2017-05-20 12:18:56 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
 'scrapy.extensions.telnet.TelnetConsole']
2017-05-20 12:18:56 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
 'scrapy.downloadermiddlewares.retry.RetryMiddleware',
 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
 'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
 'scrapy.downloadermiddlewares.stats.DownloaderStats']
2017-05-20 12:18:56 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
 'scrapy.spidermiddlewares.referer.RefererMiddleware',
 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
 'scrapy.spidermiddlewares.depth.DepthMiddleware']
2017-05-20 12:18:56 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2017-05-20 12:18:56 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-05-20 12:18:56 [scrapy.core.engine] INFO: Spider opened
Traceback (most recent call last):
  File "I:\Anaconda3\Scripts\scrapy-script.py", line 5, in 
    sys.exit(scrapy.cmdline.execute())
  File "I:\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 142, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "I:\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 88, in _run_print_help
    func(*a, **kw)
  File "I:\Anaconda3\lib\site-packages\scrapy\cmdline.py", line 149, in _run_command
    cmd.run(args, opts)
  File "I:\Anaconda3\lib\site-packages\scrapy\commands\shell.py", line 73, in run
    shell.start(url=url, redirect=not opts.no_redirect)
  File "I:\Anaconda3\lib\site-packages\scrapy\shell.py", line 48, in start
    self.fetch(url, spider, redirect=redirect)
  File "I:\Anaconda3\lib\site-packages\scrapy\shell.py", line 115, in fetch
    reactor, self._schedule, request, spider)
  File "I:\Anaconda3\lib\site-packages\twisted\internet\threads.py", line 122, in blockingCallFromThread
    result.raiseException()
  File "I:\Anaconda3\lib\site-packages\twisted\python\failure.py", line 372, in raiseException
    raise self.value.with_traceback(self.tb)
ValueError: invalid hostname: 'http

解决办法是把单引号改为双引号,即

scrapy shell “http://quotes.toscrape.com”

你可能感兴趣的:(scrapy-爬虫)