scrapy.exceptions.NotSupported: неподдерживаемая схема URL '': обработчик для этой схемы недоступен - PullRequest
0 голосов
/ 09 июля 2019

Я собираю ссылки из нескольких каталогов и затем вставляю их в start_urls как переменную ссылки

import scrapy


class SplashSpider(scrapy.Spider):
    f = open('text.txt')
    links = f.read()
    name = 'spide'
    start_urls = [str(links)]
    f.close()

    def parse(self, response):
        title = response.css('.title::text').extract()
        description = response.css("div#desc").extract()
        title = list(map(str.strip, title))
        description = list(map(str.strip, description))
        yield{
            'Title': title,
            'Main Info': description,
        }

, но у меня возникает ошибка: scrapy.exceptions.NotSupported: Unsupported URL scheme '': no handler available for that scheme

мой файл text.txt:

'https:// url1.com','https:// url2.com', ... , 'https:// url300000.com', 'https:// url300001.com'

1 Ответ

0 голосов
/ 09 июля 2019
import scrapy


class SplashSpider(scrapy.Spider):
    with open('text.txt') as f:
        links = f.readlines()
        links = list(map(lambda x: x.strip().replace(' ', ''), links))
    name = 'spider'
    start_urls = links

    def parse(self, response):
        title = response.css('.title::text').extract()
        description = response.css("div#desc").extract()
        title = list(map(str.strip, title))
        description = list(map(str.strip, description))
        yield{
            'Title': title,
            'Main Info': description,
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...