Bỏ qua để đến nội dung
MultiloginTrợ giúp

Xuất chi tiết proxy từ hồ sơ

Sử dụng script Python này để xuất cài đặt proxy được lưu trong hồ sơ trình duyệt Multilogin sang tệp JSON.

Thêm ID hồ sơ theo cách thủ công, tải từ tệp JSON hoặc sử dụng Profile Search → script gửi các ID đến Profile Metas → thông tin proxy đã xuất được lưu vào proxy_credentials.json.

Sử dụng script này khi bạn cần cài đặt proxy từ nhiều hồ sơ trình duyệt trong một tệp có cấu trúc.

Trước khi bắt đầu

  1. Đảm bảo đã cài Python, rồi cài gói bên ngoài mà script sử dụng:
    python -m pip install requests
    Mô-đun json đã có sẵn trong Python.
  2. Lưu tập lệnh proxies_to_json.py vào thư mục mong muốn của bạn

proxies_to_json.py

import json
import requests

# TODO: Insert your automation token in the variable below
API_TOKEN = ""

# Insert Your FolderID here
FOLDERID = "91f042e6-xxx-4e1f-adee-5eed6bb47d60"

# Insert your profile_ids.json filepath here
LIST_PATH = "C:/.../files/pid_list.json"

# Paste your string values manually:
LIST_MANUAL = [
    "95f6d02c-xxxx-47c4-b1d4-369801f2a37c",
    "48da90d8-xxxx-40a2-8ccb-2d9e7e3eaebb",
    "e2f9d96a-xxxx-4439-ae74-10beda6bf109",
    "fffca377-xxxx-495e-a408-3a98716e14ea",
    "f3559ca3-xxxx-479c-8a8a-c4b831e8f78b",
    "1c1e09dc-xxxx-4495-979b-7cb805a3a8a1",
    "a66ba910-xxxx-48ac-a6d1-615f996b3a1d",
    "f17140f4-xxxx-47c5-96d5-1b9fd184203b",
    "0a505d93-xxxx-4ba9-bd25-d37bf8bb168d",
]


# API-Related Objects
LOCALHOST = "http://127.0.0.1"
LAUNCHERV1 = "https://launcher.mlx.yt:45001/api/v1"
HEADERS = {"Accept": "application/json", "Content-Type": "application/json"}


# Search Profiles called "TempName": recently created by the Bulk Create function.
def profile_search():
    url = "https://api.multilogin.com/profile/search"
    body = {
        "is_removed": False,  # Do you wish to search for removed profiles? True/False
        "limit": 100,  # How many profile results do you wish to get?
        "offset": 0,  # Check MLX Documenter page for a full parameter breakdown
        "search_text": "",
        "storage_type": "all",
        "order_by": "created_at",
        "sort": "asc",
    }
    response = requests.request("POST", url, headers=HEADERS, json=body)
    resp_json = json.loads(response.content)
    return resp_json


# Obtain a list of ProfileIDs retrieved by the Profile Search endpoint
def get_profile_ids():
    profile_list = profile_search()

    if profile_list["data"]["total_count"] == 0:
        print("No more profiles found: error in response or end of task.")
        return []
    else:
        if (
            profile_list
            and "data" in profile_list
            and "profiles" in profile_list["data"]
        ):
            profile_ids = [
                profile["id"] for profile in profile_list["data"]["profiles"]
            ]
            return profile_ids
        else:
            print("Error - Please check Get Profile IDs function.")


# Use Profile Metas endpoint to get the Proxy information registrered.
def search_proxy_metas(option_call):
    url = "https://api.multilogin.com/profile/metas"

    if option_call == "1":
        payload = json.dumps({"ids": LIST_MANUAL})

    elif option_call == "2":
        payload = json.dumps({"ids": get_profile_ids()})

    elif option_call == "3":
        with open(LIST_PATH, "r") as file:
            proxies = json.load(file)
        payload = json.dumps({"ids": proxies})
    else:
        print("Invalid option. Restart.")
        return

    response = requests.request("POST", url, headers=HEADERS, data=payload)
    response_object = response.text
    extracted_data = json.loads(
        response_object
    )  # Full Profile Metas object (not only proxies)

    query_result = []

    for profile in extracted_data["data"]["profiles"]:
        proxy_metas = profile["parameters"]["proxy"]
        query_result.append(proxy_metas)

    proxy_json = json.dumps(query_result, indent=4)
    print(proxy_json)

    # Write the JSON with results
    with open("proxy_credentials.json", "w") as json_file:
        json_file.write(proxy_json)

    print(
        f"Total of {len(query_result)} proxies were saved on proxy_credentials.json \n"
    )


# Main function
def main():
    HEADERS.update({"Authorization": f"Bearer {API_TOKEN}"})

    option_call = input(
        "\n\n Select method to find proxy list: \n  (1) from PATH \n  (2) from Profile Search \n  (3) Manual List (line 14) \n Write Selection: \n   "
    )

    search_proxy_metas(option_call)


if __name__ == "__main__":
    main()
  1. Nhập giá trị vào các biến sau trong script:
    1. Nhập API token Multilogin vào biến API_TOKEN trong script.
    2. Thêm Folder ID: bạn có thể tìm giá trị này bằng hướng dẫn của chúng tôi trên DevTools hoặc Postman

Chọn hồ sơ trình duyệt cần xuất

Script có thể lấy ID hồ sơ theo ba cách:

  • Danh sách thủ công: thêm các ID hồ sơ cụ thể trực tiếp vào LIST_MANUAL
  • Profile Search: lấy hồ sơ từ không gian làm việc hiện tại
  • Tệp JSON: tải ID hồ sơ từ tệp được đặt trong LIST_PATH

Chạy script

  1. Mở terminal của bạn và điều hướng đến thư mục chứa tập lệnh
  2. Chạy tập lệnh proxies_to_json.py
  3. Chọn tùy chọn đầu vào mong muốn khi được nhắc

Bạn có thể chọn nhập danh sách ID hồ sơ của mình thông qua đường dẫn, văn bản hoặc tìm kiếm hoặc sử dụng kết quả từ điểm cuối Tìm kiếm hồ sơ.
Nếu sử dụng tùy chọn Tìm kiếm hồ sơ, hãy điều chỉnh các tham số chức năng cho phù hợp.

  1. Kiểm tra kết quả trong tệp proxy_credentials.json được lưu trữ trong cùng thư mục

Kết quả mong đợi: script tạo proxy_credentials.json trong cùng thư mục và ghi một đối tượng cấu hình proxy cho mỗi hồ sơ trình duyệt đã chọn có lưu thông tin proxy.

Đảm bảo rằng các cấu hình cho tập lệnh này có thông tin proxy. Điều này đặc biệt quan trọng đối với tùy chọn đầu vào thứ hai, vì điểm cuối Profile Search sẽ tìm kiếm 100 cấu hình đầu tiên trong không gian làm việc của bạn theo mặc định.

Luôn cập nhật

Cập nhật tin mới, chia sẻ kinh nghiệm và xem cách dùng thực tế.

Nhận tin sản phẩmKênh TelegramHỏi người khácChat TelegramXem cách dùngCộng đồng Discord