目录

Selenium 的浏览器自动化

在下面的示例中,我将向您展示如何使用 Selenium 与 GoLogin 一起工作。GoLogin 技术允许您使用 Orbita 浏览器,您可以在其中通过 puppeteer 使用独特的浏览器快照。通过在其上设置配置文件 Selenium for work with GoLogin. GoLogin technology allows you to use the Orbita browser, where you can use the unique browser snapshots through puppeteer. By setting up profiles on the gologin.com 您可以模拟各种设备、平台、屏幕分辨率、地理位置、时区、WebRTC 的可用性、指定您的代理或所需国家/地区的代理等的网站。同时将保存 cookie 和通用浏览器指纹在配置文件中,以便站点不需要重新授权,如果您需要模拟新浏览器,可以使用另一个命令更改它。 geolocation , timezone, availability of WebRTC , specify your proxies or proxies of the required country, etc. At the same time cookies and a common browser fingerprint will be saved in the profile so that the site does not require re-authorization and it can be changed with another command if you need to emulate a new browser.

Selenium 需要 chromedriver。它的最新版本与 GoLogin 一起使用位于 selenium 目录中的 github.com/gologinapp/gologin 存储库中。

Python (3.8) 给出了一个例子

完整的解析器代码如下,我会分别分析要点。


import time
from sys import platform
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from gologin import GoLogin


gl = GoLogin({
 'token': 'yU0token',
 'profile_id': 'yU0Pr0f1leiD',
})

if platform == "linux" or platform == "linux2":
 chrome_driver_path = './chromedriver'
elif platform == "darwin":
 chrome_driver_path = './mac/chromedriver'
elif platform == "win32":
 chrome_driver_path = 'chromedriver.exe'

debugger_address = gl.start()
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debugger_address)
driver = webdriver.Chrome(executable_path=chrome_driver_path, options=chrome_options)
driver.get("http://www.python.org")
assert "Python" in driver.title
driver.close()
time.sleep(3)
gl.stop()

										

第一步是创建一个GoLogin类的实例。在它的参数中,你需要指定访问令牌和我们将运行的配置文件。默认在用户目录中搜索Orbita可执行文件(可以被executablePath参数覆盖):


const GL = new GoLogin({
 profile_id: 'yU0Pr0f1leiD',
 token: 'yU0token',
});
										

然后给出启动远程浏览器的命令,并在收到链接后将其传输到 Selenium:


debugger_address = gl.start()
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debugger_address)
driver = webdriver.Chrome(executable_path=chrome_driver_path, options=chrome_options)
										

接下来访问 python.org 网站并检查我们是否到达了正确的位置:


driver.get("http://www.python.org")
assert "Python" in driver.title

										

完成工作关闭驱动程序并执行配置文件停止

这样你就可以在 GoLogin 中使用 Selenium。

运行多个账户,不受封禁和阻止
另请阅读
HydraHeaders browser

HydraHeaders 浏览器工具回顾 2024:它的用途是什么?

HydraHeaders 浏览器是一款界面过时的简单代理控制器。 我们将回顾它的功能,以及它是否能在 2024 年使用。

在线隐藏身份的 5 大最佳方式

隐藏身份并将自己从互联网搜索结果中删除的 TOP 5 方法

octo browser

Octo 浏览器与 GoLogin:浏览器反检测对比

考虑使用 Octo 浏览器工作? 我们进行了测试,计算了成本,将其与 GoLogin 进行了比较,并列出了最终表格供您选择!

我们希望听到您的问题、评论和建议。 请联系我们[email protected]或在上面留言。

您刚开始使用 GoLogin 吗? 忘掉账户暂停或终止吧。 选择任何网络平台,轻松管理多个账户。 单击此处开始使用 GoLogin 的所有功能