clash restful api 调用失败 求大家给点思路

15 天前
 momo2345

我想通过 python 调用 clash restful api 但是报错连接失败 大家能帮我看看是什么问题吗,找不到原因

下面是我的 clash 配置文件和 python 代码

参考了这个链接: https://clash.gitbook.io/doc/restful-api

clash:

mixed-port: 7890
allow-lan: true
bind-address: '*'
mode: global
log-level: info
external-controller: '127.0.0.1:9090'
secret: 29c0c9ba-1740-42c0-bb8c-dd316c5d1e4a

python:

import requests

url = 'http://127.0.0.1:9090/proxies'
secret = "29c0c9ba-1740-42c0-bb8c-dd316c5d1e4a"

headers = {
    'Authorization': f'Bearer {secret}'
}

print(requests.get(url, headers=headers).json())

报错: requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=9090): Max retries exceeded with url: /proxies (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x10580fb90>: Failed to establish a new connection: [Errno 61] Connection refused'))

我的网络状态是正常的,clash 也能正常使用,但是 restful api 调用不了,大家有什么解决思路吗,先谢谢了

552 次点击
所在节点    问与答
1 条回复
guanzhangzhang
14 天前
你抓包和 curl -v 看看呢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1071471

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX