import httpx # base_url_list = [ # "http://192.168.31.201:58001", # "http://192.168.31.201:58002", # "http://192.168.31.201:58003", # "http://192.168.31.201:58004", # "http://192.168.31.201:58005", # "http://192.168.31.201:58006", # "http://192.168.31.201:58007", # "http://192.168.31.201:58008", # "http://192.168.31.201:58009", # "http://192.168.31.201:58010", # ] base_url_list = [ "http://192.168.64.32:58001", "http://192.168.64.32:58002", "http://192.168.64.32:58003", "http://192.168.64.32:58004", "http://192.168.64.32:58005", "http://192.168.64.32:58006", "http://192.168.64.32:58007", "http://192.168.64.32:58008", "http://192.168.64.32:58009", "http://192.168.64.32:58010", "http://192.168.64.32:58011", "http://192.168.64.32:58012", ] for base_url in base_url_list: key = "/api/configs" url = base_url + key headers = { "accept": "application/json, text/plain, */*", "accept-encoding": "gzip, deflate, br, zstd", "accept-language": "zh-CN,zh", "connection": "keep-alive", "content-type": "application/json", "host": "localhost:17888", "origin": base_url, "referer": base_url, "sec-ch-ua": '"Not A(Brand";v="8", "Chromium";v="132", "Brave";v="132"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"macOS"', "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "sec-gpc": "1", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36", } # 请求体数据 data = {"mode": "Global"} # 替换为实际的请求数据 # 使用 httpx 发送 PATCH 请求 try: with httpx.Client() as client: response = client.patch(url, headers=headers, json=data) if response.status_code == 204: print(f"{base_url} 请求成功,无返回内容(204 No Content)") else: print("响应内容:", response.text) except httpx.RequestError as exc: print(f"请求失败: {exc}")