繁体   English   中英

Python Webdriver连接到已经存在的网页(硒)

[英]Python webdriver connect to already webpage (selenium)

我需要在单独的选项卡或会话中打开多个链接...我已经知道该怎么做,所以我想知道的是,是否有可能连接到一个已经打开的网页,而不是每次运行该链接时都打开每个链接。脚本。 我现在在Python中使用的是:

from selenium import webdriver
driver.get(link)

目的是一旦我运行第一个脚本(以加载多个链接),第二个脚本应连接到网页,刷新它们并继续执行代码。 可能吗? 有人知道怎么做吗?

非常感谢您的帮助!!!!

连接到先前打开的窗口很容易:

driver = webdriver.Firefox()
url = driver.command_executor._url 
session_id = driver.session_id  
driver2 = webdriver.Remote(command_executor=url,desired_capabilities={})
driver2.session_id = session_id

#You're all set to do whatever with the previously opened browser
driver2.get("http://www.stackoverflow.com")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM