简体   繁体   English

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

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

I need to open multiple links in separate tabs or sessions... I already know how to do it, so what i would like to know is if it's possible to connect to an already open webpage instead of open every links every time i run the script. 我需要在单独的选项卡或会话中打开多个链接...我已经知道该怎么做,所以我想知道的是,是否有可能连接到一个已经打开的网页,而不是每次运行该链接时都打开每个链接。脚本。 What i used now in Python is: 我现在在Python中使用的是:

from selenium import webdriver
driver.get(link)

The purpose would be once i run the first script (to load multiple links), the second should connect to the webpages, refresh them and continue with the code. 目的是一旦我运行第一个脚本(以加载多个链接),第二个脚本应连接到网页,刷新它们并继续执行代码。 Is it possible? 可能吗? Anyone know how to do it? 有人知道怎么做吗?

Thanks a lot for the help!!!! 非常感谢您的帮助!!!!

Connecting to the previously opened window is easy: 连接到先前打开的窗口很容易:

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.

相关问题 Python Selenium无法连接到Webdriver Firefox扩展 - Python Selenium cannot connect to Webdriver Firefox extension Selenium python webdriver.Firefox()无法连接 - selenium python webdriver.Firefox() fails to connect 无法使用 selenium 和 Python 连接到网页 - Cannot connect to webpage using selenium and Python 如何在python中使用selenium webdriver从网页中提取Total Confirmed的信息 - How to extract the information of Total Confirmed from webpage with selenium webdriver in python Selenium Webdriver (Python) - 无法定位网页的任何元素 - Selenium Webdriver (Python) - Unable to locate ANY element of the webpage 有没有一种方法可以使用Python / Selenium Webdriver来确认网页上是否存在jQuery? - Is there a way to confirm that jQuery is present on a webpage using Python/Selenium Webdriver? Selenium Python 的 IE webdriver 加载网页并停止 state - IE webdriver of Selenium Python loads the webpage and goes to a halt state 使用 Python + Selenium WebDriver 检查网页上是否存在文本 - Check if text exists on a webpage using Python + Selenium WebDriver Selenium webdriver 与 python 无法单击网页中的按钮 - Selenium webdriver with python can't click on a button in a webpage Python Selenium Webdriver什么也没得到,但浏览器通常显示该网页 - Python selenium webdriver gets nothing but the browser normally shows the webpage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM