Site to be scraped
我想把所有三种颜色的名字都擦掉。它们在inspect中可见,但在source中不可见。
所以我认为这是一个动态问题。Playwight不能在窗口中使用。所以我用了硒
SELENIUM_DRIVER_NAME = 'chrome'
SELENIUM_DRIVER_EXECUTABLE_PATH = 'F:\Projects\scrapspider\scrapeseams\chromedriver.exe'
SELENIUM_DRIVER_ARGUMENTS=['-headless'] # '--headless' if using chrome instead of firefox
DOWNLOADER_MIDDLEWARES = {
'scrapy_selenium.SeleniumMiddleware': 800
}
在里面
settings.py
def __init__(self):
s = Service('F:\Projects\scrapspider\scrapeseams\chromedriver.exe')
#driver = webdriver.Chrome(service=s)
# settings = get_project_settings()
# driver_path = settings['SELENIUM_DRIVER_EXECUTABLE_PATH']
chrome_options = Options()
chrome_options.add_argument('--headless')
self.driver = webdriver.Chrome(service=s,options=chrome_options)
def start_requests(self):
yield SeleniumRequest(
url = "https://in.seamsfriendly.com/collections/shorts",
wait_time = 3,
screenshot = True,
callback = self.parse1,
dont_filter = True
)
这是我的蜘蛛文件。
但我搞错了-
TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path'
如何获取所有3个名称?
我得到了其他可用的信息,但没有这个。
使现代化
如果我不使用中间件,我不会得到错误(可执行文件),但也不会得到这3个名称
response.xpath("//div[@class='swatch-navigable-wrapper']/p/text()").getall()
这就是我想要得到的