目录

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。

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

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

XPASS Browser 浏览器是供开发人员使用的浏览器指纹存储库。 我们将回顾这项服务,看看它是什么,以及如何在 2024 年使用。

PC 前 5+1 款 Web 浏览器

在本文中,我们将快速剖析最知名的 PC 网络浏览器的主要优势,它们不擅长的地方,并解释我们的选择。

网上赚钱

如何在任何地方通过网络赚钱的 33 种方法

有了好的工具,了解如何通过副业或全职网络业务在网上赚钱比以往任何时候都更容易实现。

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

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