我正在尝试从网页“https://careers.wipro.com/search-for-jobs.aspx?div=Technologies&#divhere”提取所有URL数据。此网站包含一个“加载更多”按钮,可加载更多页面。 我尝试了下面的代码,通过单击“加载更多”按钮,首先加载所有页面
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get("https://careers.wipro.com/search-for-jobs.aspx?div=Technologies&#divhere")
main_menu = driver.find_element_by_css_selector('#DivVeiwMore .button-show-more').click()
actions = ActionChains(driver)
actions.move_to_element(main_menu).click().build().perform()
上面的代码给出了以下错误
元素ClickInterceptedException:消息:元素ClickIntercepted:元素。。。在点(455863)处不可单击。其他因素会
然后我尝试使用下面的代码
url = "https://careers.wipro.com/search-for-jobs.aspx?
div=Technologies&#divhere"
driver = webdriver.Chrome()
driver.get(url)
html = driver.page_source.encode('utf-8')
page_num = 0
while driver.find_elements_by_css_selector('#DivVeiwMore .button-show-more'):
element = driver.find_element_by_css_selector('#DivVeiwMore .button-show-more').click()
driver.execute_script("arguments[0].click();", element)
page_num += 1
print("getting page number" +str(page_num))
time.sleep(10)
html=驱动程序.page\u源代码('utf-8') 上面的代码给了我另一个错误 元素ClickInterceptedException:消息:元素ClickIntercepted:元素。。。在点(455863)处不可单击。其他元素将收到单击:。。。 (会话信息:chrome=81.0.4044.138)
然后我尝试使用wait,但效果不好。请在下面查找代码和错误
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get("https://careers.wipro.com/search-for-jobs.aspx?
div=Technologies&#divhere")
main_menu =
driver.find_element_by_css_selector('a[href="javascript:void(0);"]').click()
#actions = ActionChains(driver)
#actions.move_to_element(main_menu).click().build().perform()
wait(driver, 15).until(EC.element_to_be_clickable((By.CSS_SELECTOR,
'a[href="javascript:void(0);"]'))).click()
这给了我一个错误 ElementNotInteractiableException:消息:元素不可交互
我不知道我哪里出了问题,谁能帮我点击加载更多按钮并加载所有页面,这样我就可以从页面中提取所有href元素
所观察到的是,接受cookie的通知中断了单击,并且您没有等待加载元素
有不同的方法,但我使用了1个Webdriverwait。 检查以下行是否适合您
更改驱动程序路径
相关问题 更多 >
编程相关推荐