V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cnit
V2EX  ›  分享发现

Python 大法好, AnyDesk 强制国内节点加速脚本

  •  
  •   cnit · 2022-11-01 12:01:00 +08:00 · 1682 次点击
    这是一个创建于 790 天前的主题,其中的信息可能已经有所发展或是发生改变。
    # anydesk cn relay scan https://github.com/bestK/anydesk-cn-relay-scan
    from bs4 import BeautifulSoup
    import httpx
    
    url = 'https://domain.glass/net.anydesk.com.cn'
    # anydesk 配置文件路径
    anydesk_conf = 'C:\\Users\\WIN10\\AppData\\Roaming\\AnyDesk\\system.conf'
     
    client = httpx.Client( http2=True, verify=False)
    headers = {
        'authority': 'domain.glass',
        'method': 'GET',
        'path': '/net.anydesk.com.cn',
        'scheme': 'https',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36',
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'sec-fetch-site': 'none',
        'sec-fetch-mode': 'navigate',
        'sec-fetch-dest': 'document',
        'accept-language': 'zh-CN,zh;q=0.9'
    }
    
    resp = client.get(url, headers=headers)
    soup = BeautifulSoup(resp,"html.parser")
    
    with open(anydesk_conf, mode='a') as conf:
        for a in soup.find_all('a'):
            if a.string != None and a.string.startswith('relay'):
               print(a.string)
               conf.write('\n')
               conf.write("ad.anynet.last_relay={}:80:443:6568".format(a.string))  
    
    conf.close()           
    

    灵感来源 https://www.v2ex.com/t/869623#reply5 @basncy

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2270 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 16:08 · PVG 00:08 · LAX 08:08 · JFK 11:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.