目录

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。

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

如何在浏览器中导出/导入

如何将浏览器 Cookie 从一台计算机复制到其他计算机 – 了解如何使用插件从 chrome of firefox 导出/导入 cookie。

antidetect browser

使用反检测浏览器:利用优势,规避风险

互联网是一件奇妙的事情,它永远地改变了人类。 绝…
什么是空投加密

什么是空投加密? 2024 倍增努力的指南和工具

如果您正在寻找一种简单的方法来了什么是空投加密,并加大您的空投力度,这里就是正确的地方!

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

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