Selenium 如何刮去沃尔玛的电子页面。需要帮助转到多个页面吗

Selenium 如何刮去沃尔玛的电子页面。需要帮助转到多个页面吗,selenium,scrapy,Selenium,Scrapy,我正试图浏览沃尔玛的电子产品页面,但我在浏览下一页时遇到了麻烦。我正在使用selenium迭代到下一页。你能帮忙吗 import scrapy from scrapy import Spider from scrapy.http import Request, FormRequest from selenium import webdriver from scrapy.selector import Selector class WalmartSpider(scrapy.Spider): n

我正试图浏览沃尔玛的电子产品页面,但我在浏览下一页时遇到了麻烦。我正在使用selenium迭代到下一页。你能帮忙吗

import scrapy
from scrapy import Spider
from scrapy.http import Request, FormRequest
from selenium import webdriver
from scrapy.selector import Selector


class WalmartSpider(scrapy.Spider):
name = 'walmart'
allowed_domains = ['walmart.com']
start_urls = ['https://www.walmart.com/m/electronics']

def parse(self, response):
    self.driver = webdriver.Chrome('/Users/benweiss/Downloads/chromedriver2')
    self.driver.get('https://www.walmart.com/m/electronics')
    sel = Selector(text=self.driver.page_source)
    i = 0
    while i <= 100:
        i += 1
        title = response.xpath('//a[@class="product-title-link line-clamp line-clamp-2 
 truncate-title"]/span/text()').extract()
        price = response.xpath('//span[@class="price-characteristic"]/text()').extract()
        img = response.xpath('//div[@class="orientation-square"]/img/@src').extract()
        self.driver.find_element_by_xpath('//button[@class="paginator-btn paginator-btn- 
 next"]').click()
        yield { 'title': title, 'price': price, 'img': img}
import scrapy
从刮进口蜘蛛
从scrapy.http导入请求,FormRequest
从selenium导入webdriver
从scrapy.selector导入选择器
沃尔马特蜘蛛类(刮毛蜘蛛):
名称='沃尔玛'
允许的_域=['walmart.com']
起始URL=['https://www.walmart.com/m/electronics']
def解析(自我,响应):
self.driver=webdriver.Chrome(“/Users/benweiss/Downloads/chromedriver2”)
self.driver.gethttps://www.walmart.com/m/electronics')
sel=选择器(text=self.driver.page\u源)
i=0
而我