【问题标题】:Scrapy - scrapy.exceptions.NotSupported: Unsupported URL scheme '': no handler available for that schemeScrapy - scrapy.exceptions.NotSupported:不支持的 URL 方案'':没有可用于该方案的处理程序
【发布时间】:2018-01-24 00:10:43
【问题描述】:

我正在尝试从网站上删除几个页面。 为此,我使用循环来添加我的 URL 的页码。 当我启动我的蜘蛛时,我遇到了这个错误。 我将引用从单引号更改为双引号,或者检查是否有空格,但 URL 似乎很好。

你知道出了什么问题吗?

我的循环

> def url_lister():
>     url_list = []
>     page_count = 0
>     while page_count < 2: 
>         url = "['https://www.active.com/running?page=%s" %page_count + "']"
>         url_list.append(url)
>         print(url)
>         page_count += 1 
>     return url_list

以下是结果网址

['https://www.active.com/running?page=0']
-----------------------------
['https://www.active.com/running?page=1']
-----------------------------
["['https://www.active.com/running?page=0']", "['https://www.active.com/running?page=1']"]
-----------------------------

这是消息错误

2018-01-23 14:31:34 [scrapy.middleware] INFO: Enabled item pipelines:
['ACTIVE.pipelines.ActivePipeline']
2018-01-23 14:31:34 [scrapy.core.engine] INFO: Spider opened
2018-01-23 14:31:34 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2018-01-23 14:31:34 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2018-01-23 14:31:34 [scrapy.downloadermiddlewares.robotstxt] ERROR: Error downloading <GET :///robots.txt>: Unsupported URL scheme '': no handler available for that scheme

【问题讨论】:

    标签: url scrapy


    【解决方案1】:

    经过几次测试,我更改了我的代码,它可以工作了:

    旧代码

    def url_lister():
        url_list = []
        page_count = 0
        while page_count < 2: 
            url = "['https://www.active.com/running?page=%s" %page_count + "']"
            url_list.append(url)
            print(url)
            page_count += 1 
        return url_list
    

    新代码

    def url_lister():  
        url_list = []
        page_count = 0
        while page_count < 480: 
            url = 'https://www.active.com/running?page=%s' %page_count 
            url_list.append(url)
            page_count += 1 
        return url_list
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-21
      • 1970-01-01
      相关资源
      最近更新 更多