Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 移动到下一页时,使用Get_table func获取更新的值(使用Selenium)_Python_Selenium_Selenium Webdriver_Rendering - Fatal编程技术网

Python 移动到下一页时,使用Get_table func获取更新的值(使用Selenium)

Python 移动到下一页时,使用Get_table func获取更新的值(使用Selenium),python,selenium,selenium-webdriver,rendering,Python,Selenium,Selenium Webdriver,Rendering,每个页面搜索结果都有一个“gs per result labels”类,我从中提取URL,但当我呈现到下一个页面时,仍然会得到旧值 import requests import bs4 from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By fro

每个页面搜索结果都有一个“gs per result labels”类,我从中提取URL,但当我呈现到下一个页面时,仍然会得到旧值


import requests
import bs4
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time



def get_table():
    search = driver.find_elements_by_class_name("gs-per-result-labels")
    for link in search:
        print(link.get_attribute("url"))

PATH = 'C:\Program Files (x86)\chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get("https://www.cvedetails.com/google-search-results.php?q=tcp&sa=Search")



#get_table()

pages = range(2,11)
for i in pages:
通过迭代,我给出了所有页面的xpath`

 

    elements = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,'/html/body/table[1]/tbody/tr[2]'
                                                                                   '/td[2]/div/div/div/div/div/div/'
                                                                                   'div[5]/div[2]/div/div/div[2]/'
                                                                                   'div/div['+str(i)+']')))

    get_table()

然而,即使页面继续移动,我也会得到与第一页相同的URL

    elements.click()

    #elems = WebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "gs-title")))