有一个表是动态的,要获取该表,需要从名为PRO LISTS
的dropdownlist中单击CS:GO
。我试过了,但无法选择正确的定位器。谢谢
我尝试了以下方法:
#driver.find_element_by_xpath('(//i[@class="x-anchor-sub-indicator"])[1]').click()
#time.sleep(5)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '(//*[@class="sub-menu x-dropdown x-active"]/li/a)[1]'))).click()
driver.execute_script("arguments[0].click();", driver.find_element_by_xpath('(.//*[@class="sub-menu x-dropdown x-active"]/li/a)[1]/div/div/span'))
更新:
import scrapy
from scrapy.selector import Selector
from scrapy_selenium import SeleniumRequest
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
class DropdownScrollTable(scrapy.Spider):
name = 'dst'
def start_requests(self):
yield SeleniumRequest(
url='https://prosettings.net/cs-go-pro-settings-gear-list/',
wait_time=5,
screenshot=True,
callback=self.parse)
def parse(self, response):
driver = response.meta['driver']
wait = WebDriverWait(driver, 20)
ActionChains(driver).move_to_element(wait.until(EC.visibility_of_element_located((By.XPATH, "//span[contains(text(),'Pro Lists')]/ancestor::a")))).pause(5).perform()
wait.until(EC.visibility_of_element_located((By.XPATH, "//span[contains(text(),'CS:GO')]/ancestor::a"))).click()
driver.save_screenshot('search_result.png')
需要记录的事项:
CS:GO
代码
导入:
相关问题 更多 >
编程相关推荐