最受欢迎主题: Multilogin X, Multilogin 6, 订阅 & 支付,
如何使用 Script runner 启动CookieRobot
目录
CookieRobot可自动从您选择的网站收集 Cookie,让您的配置文件看起来更加真实并且无需手动抓取!在本指南中,我们将引导您了解如何使用它来简化流程。
已经熟悉自动化或已完成一些步骤?使用右侧的目录直接跳转到所需内容。开始吧!
步骤 1:设置你的 Postman
在使用 Postman 运行Multilogin X API端点和自动化之前,请确保更新并连接您的Agent。
从他们的官方页面下载并安装 Postman。
安装Postman后,打开Multilogin X API页面:
- 在右上角,点击“在 Postman 中运行”
- 选择“适用于 <您的操作系统> 的 Postman”
您的 Postman 桌面将打开。请将所有API端点导入到您的本地集合:
- 在“导入收藏”中 → 选择您的工作区
- 点击“导入” → 所有端点将在文件夹中可用


通过 Postman 登录
您需要使用您的凭据登录以生成API令牌,该令牌授予您访问API端点和执行操作的权限。
找到用户登录端点
- 打开“收藏” → 展开“ Multilogin X API ”文件夹
- 打开“配置文件访问管理”文件夹
- 选择POST用户登录端点(什么是 POST 请求?)

将您的密码转换为 MD5
您需要使用用户登录端点来获取您的访问令牌,但有一个问题:您的密码需要加密为 MD5。
以下是如何使用MD5 哈希生成器获取加密密码的方法:
- 输入您的Multilogin X密码
- 点击“生成”
- 复制你的MD5加密密码

获取API令牌
常规令牌有效期为30 分钟。如果您有Solo计划(或更高版本),请使用工作区自动化令牌端点以获得更长时间的选项。
- 在POST用户登录时 →转到“Body”选项卡
- 以
“strings”
形式填写您的电子邮件和 MD5 密码 - 发送登录请求

- 检查下面响应区域中的访问令牌→复制引号内的所有内容

第 2 步:打开 Script Runner
保持更新: Script Runner 需要 Agent 1.37.4 或更新版本。如果不确定,请按照此处的步骤检查您的 Agent 版本。
现在您已登录并拥有令牌,您即可使用Script Runner 端点并运行您的CookieRobot脚本!
- 返回“收藏” → “ Multilogin X API ”文件夹
- 转到“Script Runner”文件夹
- 打开POST Start Script Runner端点来配置新的API请求!

- 从“参数”选项卡,进入“Authorization”
- 选择“ Bearer Token ”作为身份验证类型
- 在右侧的Token字段中,粘贴之前复制的API token

使用 Bearer Token 填写“Authorization”选项卡后,您就可以在 Script Runner 中发送启动CookieRobot的请求!🔑
添加CookieRobot脚本
CookieRobot目前支持所有类型的浏览器配置文件,除移动配置文件外。
将令牌插入“Authorization”选项卡后:
- 继续看到“Body”选项卡
- 确保选择了raw参数
- 插入如下所示的CookieRobot请求体(JSON):
{
"script_file": "cookie_robot.py",
"profile_ids": [
{
"profile_id": "profile uuid"
},
{
"profile_id": "profile uuid",
"is_headless": true
}
],
"script_params": [
{
"name": "websites",
"value": ["https://youtube.com","https://google.com","https://fb.com","https://amazon.com"]
},
{
"name": "randomOrder",
"value": true
},
{
"name": "fractionMode",
"value": 0.7
},
{
"name": "processCookieConsent",
"value": true
}
]
}

CookieRobot脚本的名称是cookie_robot.py
。它已添加到“script_file”
行,因此无需手动更新它。
步骤3:自定义参数
启动CookieRobot时,有几个可自定义的参数会影响抓取过程的工作方式。这些参数允许用户调整目标网站、抓取顺序等设置。通过在“script_params”
部分中微调这些选项,用户可以根据自己的特定需求优化脚本的性能。
可定制的CookieRobot参数在屏幕截图和下图中以红色突出显示:

“profile_ids”
包含配置文件ID的列表,结构如下:
-
“profile_id”
– 唯一的配置文件ID号码 -
“is_ headless ”
– (可选)在headless模式下运行可能限制配置文件与某些页面元素的交互
“script_params”
包含一组可自定义参数的列表,简单表示为:
-
“name”
– 参数名称 -
“value”
– 指定的值(字符串、整数、浮点数、JSON 等)
“websites”
如果“websites”
参数中没有提供任何内容,配置文件将使用其默认列表:
websites = [
"https://aliexpress.com",
"https://amazon.com",
"https://ebay.com",
"https://fiverr.com",
"https://google.com",
"https://reddit.com",
"https://twitch.com",
"https://twitter.com",
"https://yahoo.com",
"https://youtube.com",
"https://en.wikipedia.org"
]
我们建议从多个来源收集 Cookie,以获得更真实的指纹。查看收集 Cookie:我们的提示文章了解更多信息。
“randomOrder”
“fractionMode”
想要运行网站的一部分,而不是全部?查看如何使用:
- 选择 0.0 到 1.0 之间的浮点数来设置要运行抓取站点的比例
- 确保
“randomOrder”
设置为“true”
例如:如果使用"fractionMode"= “0.5”
,它将以随机顺序运行抓取 50% 的网站列表
“processCookieConsent”
由于 GDPR(什么是 GDPR? )等隐私法限制,许多网站都会显示“允许 Cookie”按钮,该法案要求在设置跟踪 Cookie 之前获得用户同意。
- 设置为
“true”
→ CookieRobot将自动查找并尝试点击同意按钮(默认) - 设置为
“false”
→它将忽略 cookie 弹出窗口,这在以下情况下很有用:- 您正在浏览不显示 Cookie 横幅的非欧盟网站
- 您不关心 GDPR 合规性(例如,使用欧盟以外的代理)
步骤 4:运行CookieRobot
根据需要配置参数后:
- 单击“Send”以运行POST Start Script Runner请求
- 检查请求响应: 状态200 正常 意味着成功!
- 您的CookieRobot脚本将启动所选配置文件。如果不是headless ,您将能实时观看抓取过程!🔍
如果你得到 发送请求时出现401 未授权错误,您的令牌可能已过期:
如果发生这种情况,请重复“获取API令牌”中的步骤以生成新的 Bearer Token。

补充:想看关于此过程的 Python 示例代码吗?
在此示例中,所有设置将在payload
对象中的run_script()
内进行配置,包括:
- CookieRobot将通过文件
cookie_robot.py
运行 - 使用的配置文件ID设置为
ced16576-a67b-4ae5-8459-c07991d50f27
和ec0cf95f-b199-4b1c-b394-af1e01ac9c09
- 两种配置文件都将在非headless模式下运行
- 这些网站是 Yahoo.com 和 Amazon.com,将按随机顺序访问它们
- 由于
fractionMode
设置为 1,因此列出的网站 100% 都会被访问。 - 如果出现CookieRobot同意通知,它将自动接受
import logging
import requests
import json
# In project root you need a file called token with your auth token in there
def setup_logging():
"""Set up logging configuration."""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler("script_runner.log"),
logging.StreamHandler()
]
)
def get_token_from_file():
"""Read the token from a file called 'token' in the project root."""
try:
with open("token", "r") as file:
token = file.read().strip()
return token
except FileNotFoundError:
logging.error("Token file not found in the project root.")
raise
except Exception as e:
logging.error("An error occurred while reading the token file: %s", str(e))
raise
def run_script():
url = "https://launcher.mlx.yt:45001/api/v1/run_script"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {get_token_from_file()}"
}
payload = {
"script_file": "cookie_robot.py",
"profile_ids": [
{
"profile_id": "ced16576-a67b-4ae5-8459-c07991d50f27",
"is_headless": False
},
# {
# "profile_id": "ec0cf95f-b199-4b1c-b394-af1e01ac9c09",
# "is_headless": False
# },
],
"script_params": [
{
"name": "websites",
"value": ["yahoo.com", "amazon.com"]
},
{
"name": "randomOrder",
"value": True
},
{
"name": "fractionMode",
"value": 1
},
{
"name": "processCookieConsent",
"value": True
}
]
}
try:
logging.info("Payload to send: %s", json.dumps(payload, indent=4))
logging.info("Sending request to the script runner endpoint...")
response = requests.post(url, headers=headers, data=json.dumps(payload), timeout=30)
if response.status_code == 200:
logging.info("Script executed successfully.")
logging.info("Response: %s", response.json())
else:
logging.error("Failed to execute script. Status code: %d", response.status_code)
logging.error("Response: %s", response.text)
except requests.exceptions.RequestException as e:
logging.error("An error occurred while making the request: %s", str(e))
if __name__ == "__main__":
setup_logging()
run_script()