Python 元素单击Selenium未找到按钮以单击

Python 元素单击Selenium未找到按钮以单击,python,pandas,selenium,selenium-webdriver,xpath,Python,Pandas,Selenium,Selenium Webdriver,Xpath,对于下面的url,我尝试单击“1-50”按钮(它有自己的xpath),然后单击“51-100”、“101-150”等按钮(它们都共享第二个xpath),但我的代码似乎无法单击该按钮。有人能弄明白吗?干杯 import pandas as pd import time from selenium import webdriver from bs4 import BeautifulSoup driver = webdriver.Chrome() url = 'www.sec.gov/securit

对于下面的url,我尝试单击“1-50”按钮(它有自己的xpath),然后单击“51-100”、“101-150”等按钮(它们都共享第二个xpath),但我的代码似乎无法单击该按钮。有人能弄明白吗?干杯

import pandas as pd
import time
from selenium import webdriver
from bs4 import BeautifulSoup
driver = webdriver.Chrome()

url = 'www.sec.gov/securities/files/year/'

page = driver.get(url)
time.sleep(2)

df_appended = []

df = pd.read_html(driver.page_source)[0]
df_appended.append(df)
    
time.sleep(2)
driver.find_element_by_xpath('//[@id="ctl00_m_g_00806bcd_0028_4082_9797_52f6f350e592_updatePanelctl00_m_g_00806bcd_0028_4082_9797_52f6f350e592"]/table[2]/tbody/tr/td/a/img').click
time.sleep(2)

for i in range(1,3):
    df = pd.read_html(driver.page_source)[0]
    df_appended.append(df)
    driver.find_element_by_xpath('//*[@id="ctl00_m_g_00806bcd_0028_4082_9797_52f6f350e592_updatePanelctl00_m_g_00806bcd_0028_4082_9797_52f6f350e592"]/table[2]/tbody/tr/td/a[3]/img').click()
    time.sleep(1)
    
df_appended

如果使用a标记,则运行良好

driver.find_element_by_xpath('//table[2]/tbody/tr/td/a').click()
time.sleep(2)

for i in range(1,3):
    df = pd.read_html(driver.page_source)[0]
    df_appended.append(df)
    driver.find_element_by_xpath('//table[2]/tbody/tr/td/a[3]').click()
    time.sleep(1)

如果使用a标记,则运行良好

driver.find_element_by_xpath('//table[2]/tbody/tr/td/a').click()
time.sleep(2)

for i in range(1,3):
    df = pd.read_html(driver.page_source)[0]
    df_appended.append(df)
    driver.find_element_by_xpath('//table[2]/tbody/tr/td/a[3]').click()
    time.sleep(1)