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


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

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

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

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

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

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

使用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 ”– (可选)在无头模式下运行可能限制配置文件与某些页面元素的交互
“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? )等隐私法限制,许多网站都会显示“Allow Cookies”按钮,该法案要求在设置跟踪Cookie之前获得用户同意。
- 设置为
“true”→ CookieRobot将自动查找并尝试点击同意按钮(默认) - 设置为
“false”→它将忽略cookie弹出窗口,这在以下情况下很有用:- 您正在浏览不显示Cookie横幅的非欧盟网站
- 您不担心GDPR合规性(例如,使用欧盟以外的全局IP)
步骤4:运行CookieRobot
根据需要配置参数后:
- 单击“Send”以运行POST Start Script Runner请求
- 检查请求响应: 状态200 正常意味着成功!
- 您的CookieRobot脚本将启动所选配置文件。如果是无头的 ,您将不能实时观看抓取过程!🔍
如果您发送请求时出现401 未授权错误,您的令牌可能已过期:
如果发生这种情况,请重复“获取API令牌”中的步骤以生成新的Bearer Token。

补充:想看关于此过程的Python示例代码吗?
在此示例中,所有设置将在payload对象中的run_script()内进行配置,包括:
- CookieRobot将通过文件
cookie_robot.py运行 - 使用的配置文件ID设置为
ced16576-a67b-4ae5-8459-c07991d50f27和ec0cf95f-b199-4b1c-b394-af1e01ac9c09 - 两种配置文件都将在非无头模式下运行
- 这些网站是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()