У меня проблема с scrapy_selenium "selenium.common.exceptions.InvalidArgumentException: Сообщение: недопустимый аргумент" - PullRequest
0 голосов
/ 07 мая 2020

Я новичок в веб-парсинге и селене. Я написал код для простого парсинга, но с одной ошибкой. Не могли бы вы посоветовать мне, как я могу решить эту проблему. спасибо вот мой код:

# -*- coding: utf-8 -*-
import scrapy
from scrapy.selector import Selector
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from shutil import which


class CoinSpiderSelenium(scrapy.Spider):
    name = 'coin_selenium'
    allowed_domains = ['www.livecoin.net/en']
    start_urls = ['https://www.livecoin.net/en/']


    def __init__(self):
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        chrome_path = which("chromedriver")
        driver = webdriver.Chrome(executable_path=chrome_path, options=chrome_options)

        driver.get("www.livecoin.net/en")
        tab = driver.find_elements_by_class_name("filterPanelItem___2z5Gb")
        tab[4].click()
        self.html = driver.page_source
        driver.close()

    def parse(self, response):
        resp = Selector(text=self.html)
        for currency in resp.xpath("//div[contains(@class, 'ReactVirtualized__Table__rowColumn tableRowColumn___rDsl0')]"):
            yield {
                'Currency_Pair' :   currency.xpath(".//div[1]/text()").get(),
                'volume'        :   currency.xpath(".//div[2]/span/text()").get()
            }
...