我正在尝试自动获取URL缩短的结果。 这是我正在使用的页面:url shortener site
这是我编写的代码(URL列表包含链接):
driver.get("http://paylinx.pw/linx/")
for i in URLS:
driver.find_element_by_xpath('//*[@id="url"]').click()
time.sleep(2)
driver.find_element_by_xpath('//*[@id="url"]').send_keys(i)
time.sleep(2)
driver.find_element_by_xpath('//*[@id="invisibleCaptchaShort"]').click()
time.sleep(2)
在这之后,我得到了shortened url
。我需要一点帮助才能弄到它
使用
WebDriverWait
等待短url结果并获取值要自动提取URL缩短器的结果值,您需要为
visibility_of_element_located()
引入WebDriverWait,并且可以使用以下Locator Strategies:代码块:
控制台输出:
您需要使用page.source,因为它可以根据需要翻译页面代码(对于chromedriver,如lifehuck),或者您可以使用get_属性('innerHTML')-您可以访问页面中的所有内容
Python WebDriver how to print whole page source (html)
相关问题 更多 >
编程相关推荐