from scrapy import Spider
from scraper_cial.items import ResultItem
from scraper_cial.spiders.use_cases.extract_logo_url_use_case import extract_logo_url_use_case
from scraper_cial.spiders.use_cases.extract_phone_numbers_use_case import extract_phone_numbers_use_case


class CialTestSpider(Spider):
    name = 'cial_test'

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.start_urls = [line.strip()
                           for line in open(0).readlines()]

    def parse(self, response):
        logo = extract_logo_url_use_case(response.xpath, response.url)
        phones = extract_phone_numbers_use_case(response.xpath, response.text)

        yield ResultItem(logo=logo,
                         phones=phones,
                         website=response.url)

from scrapy import Spider
from scraper_cial.items import ResultItem
from scraper_cial.spiders.use_cases.extract_logo_url_use_case import extract_logo_url_use_case
from scraper_cial.spiders.use_cases.extract_phone_numbers_use_case import extract_phone_numbers_use_case


class CialTestSpider(Spider):
    name = 'cial_test'

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.start_urls = [line.strip()
                           for line in open(0).readlines()]

    def parse(self, response):
        logo = extract_logo_url_use_case(response.xpath, response.url)
        phones = extract_phone_numbers_use_case(response.xpath, response.text)

        yield ResultItem(logo=logo,
                         phones=phones,
                         website=response.url)
