From 7a8102cf1b7e9f9d71ef1f3a71812f13eff12246 Mon Sep 17 00:00:00 2001 From: raileo98 <164594063+raileo98@users.noreply.github.com> Date: Sat, 19 Oct 2024 03:45:15 +0000 Subject: [PATCH] Update rthk.py --- code/rthk.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/code/rthk.py b/code/rthk.py index 998faa2af..caf779d3e 100644 --- a/code/rthk.py +++ b/code/rthk.py @@ -77,6 +77,23 @@ def check(): 'https://images.weserv.nl/quota' ] + for url in urls: + try: + headersForCheck = dict(session.headers) + headersForCheck['Cache-Control'] = 'no-cache' + headersForCheck['Pragma'] = 'no-cache' + print( f'headersForCheck: { headersForCheck }' ) + response = get_response.get(url, timeout=2, headers=headersForCheck ) + if response.ok: + # print(f'使用代理獲取 {url} 成功: \nhttp_version: {response.http_version} \n{response.text}\n') + print(f'使用代理獲取 {url} 成功: \n{response.text}\n') + else: + print(f'使用代理獲取 {url} 失敗:\n{response.status_code}\n') + except Exception as e: + print(f'使用代理獲取 {url} 出錯:\n{e}\n') + except: + print(f'使用代理獲取 {url} 出現未知錯誤\n') + for url in urls: try: headersForCheck = dict(session.headers)