V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
momo2345
V2EX  ›  问与答

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

  •  
  •   momo2345 · Sep 10, 2024 · 1574 views
    This topic created in 598 days ago, the information mentioned may be changed or developed.

    我想通过 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 调用不了,大家有什么解决思路吗,先谢谢了

    1 replies    2024-09-10 11:09:55 +08:00
    guanzhangzhang
        1
    guanzhangzhang  
       Sep 10, 2024
    你抓包和 curl -v 看看呢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1408 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 16:27 · PVG 00:27 · LAX 09:27 · JFK 12:27
    ♥ Do have faith in what you're doing.