主程序是调用PUBG的API来获取玩家数据,脚本没有用到代{过}{滤}理,偶尔会出现以下报错信息
我的程序代码:
import requests
from datetime import datetime, timedelta
from PIL import Image, ImageDraw, ImageFont
import sys
import os
import requests
from PIL import Image
from io import BytesIO
import requests.exceptions
player_id = sys.argv[1] if len(sys.argv) > 1 else ""
headers = {
"Authorization": "Bearer api key",
"Accept": "application/vnd.api+json"
}
def get_player_data(player_id):
url = f"https://api.pubg.com/shards/steam/players?filter[playerNames]={player_id}"
try:
response = requests.get(url, headers=headers)
except requests.exceptions.RequestException as e:
print(f"error:{e}")
sys.exit(3)
if response.status_code == 429:
sys.exit(2)
elif response.status_code in [400, 404]:
sys.exit(1)
else:
data = response.json()
ban_type = data['data'][0]['attributes']['banType'] if 'data' in data and data['data'] else None
account_id = data['data'][0]['id'] if 'data' in data and data['data'] else None
return data, ban_type, account_id
环境:
C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.exe
OS Windows-2012ServerR2-6.3.9600-SP0
Python 3.9.13
OpenSSL 1.1.1n 15 Mar 2022
urllib3 1.25.11
错误信息:
HTTPSConnectionPool(host='api.pubg.com', port=443):
Max retries exceeded with url: /shards/steam/players?filter%5BplayerNames%5D=Dai
lyMidv_x (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protoc
ol (_ssl.c:1129)')))
|