Python:如何使用 Python 从“localhost:2999/liveclientdata/playerlist”在英雄联盟冠军选择中读取 json?

问题描述

我想使用 Python (3.9) 创建一个应用程序来读取英雄联盟冠军选择中的信息。 我发现我需要访问以获取信息的端口是端口“2999”(source)。

问题是我的防火墙阻止了我,无论我使用的是 Python 还是我的 Web 浏览器,但我不需要在我的防火墙上手动允许访问,因为这个应用程序应该(免费)共享给那些只是想玩,连“防火墙”是什么意思都不知道。

即使在尝试以下代码后,除了错误消息之外,我什么也得不到:Python: How can I use urllib or requests modules from a corporate domain (firewall,proxy,cntlm etc)

这是我尝试获取所需信息的最新代码

import urllib.request
from time import sleep

proxy = urllib.request.ProxyHandler({
    'http': 'localhost:2999','https': 'localhost:2999'
})
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)

for _ in range(30):
    try:
        data = urllib.request.urlopen('https://127.0.0.1:2999/liveclientdata/playerlist').read()
    except urllib.error.URLError as e:
        print(e)
    sleep(1)

这是我收到的错误消息:<urlopen error [WinError 10061] No connection Could be made because the target machine actively refused it>

预期输出A json file containing keys such as "userID","puuid" and "summonerLevel"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)