【发布时间】:2020-02-18 07:57:53
【问题描述】:
我在 python 中使用网络爬虫库作为 [Selenium]。 我想提交一个表单(没有 AJAX 的多个表单)
所以,我写了这段代码:
from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('https://exportgram.com/')
one = driver.find_element_by_xpath('//*[@id="home"]/form/div[1]/div/input[1]')
one.click()
one.send_keys('https://www.instagram.com/p/B6OCVnTglgz/')
two = driver.find_element_by_xpath('//*[@id="home"]/form/div[2]/button')
two.click()
time.sleep(3)
three = driver.find_element_by_xpath('//*[@id="home"]/form/div[2]/button')
three.click()
现在,我无法访问“三”,因为这在新页面上可用。
没有办法解决这个问题吗?
[注意:点击“二”后,页面变为“https://example.com/media.php”]
【问题讨论】:
-
页面更改后,添加等待获取元素,因为它可能是页面加载并且该元素在 HTML 内容中不可点击。
标签: python selenium web-scraping scrape