MinhZou / FudanCourtReservation

FudanCourtReservation 是一个用于自动预约复旦体育场馆(如羽毛球,网球等)的 Python 脚本
MIT License
13 stars 5 forks source link

求问为什么总是出现ssl连接问题 #3

Closed cocoILoveYoucoco closed 1 week ago

cocoILoveYoucoco commented 2 weeks ago

[2024-08-30 15:45:02,204 - root - INFO - 89837 - 7961661440] 成功获取cookie!!! [2024-08-30 15:45:02,204 - root - INFO - 89837 - 7961661440] NSC_Xfc-DpoufouTxjudi-443=ffffffff096ca61a45525d5f4f58455e445a4a423660; JSESSIONID=116CD1FD7FF2497D533EA8E0C8F1E6F0; iPlanetDirectoryPro=evcaMsgg2TASebvBuGaD0M; Process Process-4: urllib3.exceptions.SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 843, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/util/retry.py", line 519, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='elife.fudan.edu.cn', port=443): Max retries exceeded with url: /public/userbox/index.htm?userConfirm=&orderstateselect= (Caused by SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 108, in run self._target(*self._args, self._kwargs) File "/Users/macbook/Downloads/FudanCourtReservation-main/scripts/client.py", line 403, in single_job self.get_status() File "/Users/macbook/Downloads/FudanCourtReservation-main/scripts/client.py", line 296, in get_status resource_resp = requests.get(status_url, headers=headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/adapters.py", line 698, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='elife.fudan.edu.cn', port=443): Max retries exceeded with url: /public/userbox/index.htm?userConfirm=&orderstateselect= (Caused by SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)'))) [2024-08-30 15:45:53,712 - root - INFO - 89850 - 7961661440] 成功获取cookie!!! [2024-08-30 15:45:53,712 - root - INFO - 89850 - 7961661440] NSC_Xfc-DpoufouTxjudi-443=ffffffff096ca61a45525d5f4f58455e445a4a423660; JSESSIONID=26046B3D8EB933456B86AEAED20D5CF1; iPlanetDirectoryPro=wtqcCYWq0QqbdWAqj7brhb; Process Process-5: urllib3.exceptions.SSLError: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py", line 843, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/util/retry.py", line 519, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='elife.fudan.edu.cn', port=443): Max retries exceeded with url: /public/userbox/index.htm?userConfirm=&orderstateselect= (Caused by SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 108, in run self._target(*self._args, self._kwargs) File "/Users/macbook/Downloads/FudanCourtReservation-main/scripts/client.py", line 403, in single_job self.get_status() File "/Users/macbook/Downloads/FudanCourtReservation-main/scripts/client.py", line 296, in get_status resource_resp = requests.get(status_url, headers=headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/requests/adapters.py", line 698, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='elife.fudan.edu.cn', port=443): Max retries exceeded with url: /public/userbox/index.htm?userConfirm=&orderstateselect= (Caused by SSLError(SSLError(1, '[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)')))

cocoILoveYoucoco commented 2 weeks ago

已经求助了ai但是怎么调都还是这样:

从错误信息来看,问题出在 SSL 连接上。具体错误是 [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1000)。这通常是由于服务器不支持现代的 SSL/TLS 安全协议或配置导致的。

以下是解决这个问题的几种方法:

方法一:使用 requests 库的 verify 参数

你可以尝试在 requests.get 调用中禁用 SSL 验证。请注意,这会降低安全性,仅在测试环境中使用。

client.py 文件中,找到 requests.get 调用,并添加 verify=False 参数:

resource_resp = requests.get(status_url, headers=headers, verify=False)

方法二:更新 requests

确保你使用的是最新版本的 requests 库。你可以通过以下命令更新 requests 库:

pip install --upgrade requests

方法三:使用 urllib3HTTPSConnection

你可以尝试使用 urllib3 库来手动处理 SSL 连接。以下是一个示例:

import urllib3

http = urllib3.PoolManager()
response = http.request('GET', status_url, headers=headers)

方法四:配置 SSL 环境

你可以尝试配置 SSL 环境,使其支持旧的 SSL/TLS 协议。以下是一个示例:

import ssl
import requests

# 创建自定义的 SSL 上下文
context = ssl.create_default_context()
context.options |= ssl.OP_LEGACY_SERVER_CONNECT

# 使用自定义的 SSL 上下文进行请求
resource_resp = requests.get(status_url, headers=headers, context=context)

方法五:使用 requestsSession 对象

你可以使用 requestsSession 对象来管理连接,并设置 SSL 上下文:

import requests
import ssl

# 创建自定义的 SSL 上下文
context = ssl.create_default_context()
context.options |= ssl.OP_LEGACY_SERVER_CONNECT

# 创建 Session 对象
session = requests.Session()
session.verify = False  # 禁用 SSL 验证

# 使用 Session 对象进行请求
resource_resp = session.get(status_url, headers=headers)

总结

通过以上步骤,你应该能够解决 SSL 连接问题,并成功运行脚本。如果问题依然存在,建议检查你的 Python 安装和环境配置,确保所有步骤都正确执行。

cocoILoveYoucoco commented 2 weeks ago

求求解答!!(我是电脑小白,只会靠模型改代码)

MinhZou commented 2 weeks ago

多半是挂vpn的原因,其他可能原因参考另外一个回答 #1

cocoILoveYoucoco commented 2 weeks ago

我回头再试试,谢谢!

MinhZou commented 2 weeks ago

你再试试吧,我刚试了下,还是可以成功运行的。

[2024-08-30 16:11:51,580 - root - INFO - 32560 - 41584] 成功填充账号和密码!!! [2024-08-30 16:12:03,892 - root - INFO - 32560 - 41584] 成功获取cookie!!! [2024-08-30 16:12:03,893 - root - INFO - 32560 - 41584] NSC_Xfc-DpoufouTxjudi-443=xxxx; JSESSIONID=xxx; iPlanetDirectoryPro=xxxx; [2024-08-30 16:12:04,265 - root - INFO - 32560 - 41584] 已预定{} [2024-08-30 16:12:04,268 - root - INFO - 32560 - 41584] 江湾体育馆排球场1号 2024-09-01 无场地可约 [2024-08-30 16:12:04,270 - root - INFO - 32560 - 34840] 获取ID中... [2024-08-30 16:12:04,684 - root - INFO - 32560 - 22000] 获取ID中... [2024-08-30 16:12:11,099 - root - INFO - 32560 - 41584] 已预定{} [2024-08-30 16:12:11,101 - root - INFO - 32560 - 41584] 江湾体育馆排球场1号-2024-09-01 08:00 可约, ID为8aecc6ce8d17fc0e018d6d7d88217d51 [2024-08-30 16:12:11,101 - root - INFO - 32560 - 41584] 江湾体育馆排球场1号-2024-09-01 09:00 可约, ID为8aecc6ce8d17fc0e018d6d7d88217d53 [2024-08-30 16:12:11,102 - root - INFO - 32560 - 41584] 正在预定江湾体育馆排球场1号-2024-09-01 09:00

DevTools listening on ws://127.0.0.1:3996/devtools/browser/b59cc596-1128-4d50-afbf-c2447ae695a7 Successfully retrieved valid text: 心旷神怡 Successfully retrieved captcha results: {'旷': {'left': 117, 'top': 120}, '心': {'left': 41, 'top': 56}, '怡': {'left': 264, 'top': 130}, '神': {'left': 182, 'top': 108}} Verification passed! [0830/161225.102:INFO:CONSOLE(648)] "Uncaught TypeError: $(...).combobox is not a function", source: https://elife.fudan.edu.cn/js/system.js (648) [2024-08-30 16:12:28,900 - root - INFO - 32560 - 41584] 已预定{'09-01-09:00': '8aecc6ce90ae440c0191a257b8ab2675'} [2024-08-30 16:12:28,901 - root - INFO - 32560 - 41584] {'09-01-09:00': '8aecc6ce90ae440c0191a257b8ab2675'} [2024-08-30 16:12:28,901 - root - INFO - 32560 - 41584] 09-01-09:00 [2024-08-30 16:12:29,856 - root - INFO - 32560 - 41584] 邮件发送成功! [2024-08-30 16:12:30,183 - root - INFO - 32560 - 41584] 已预定{'09-01-09:00': '8aecc6ce90ae440c0191a257b8ab2675'}

cocoILoveYoucoco commented 2 weeks ago

btw想请教一下怎么同时设置预约多个时间的呢?或者说怎么设置预约的优先级的?

MinhZou commented 2 weeks ago

直接像这样增加多个时间段就行,优先级以前写过一些版本,但是在实际场景中并不好用,因为等反馈回来一个场地没有的时候,其他场地很大概率也没有了,所有都是同时的,不考虑优先级

user6: username: 'xxx' password: 'xxx' orderuser: 'xxx' mobile: 'xxx' email: 'xxx' court_name: '江湾体育馆羽毛球场' stage_1:

下面是同时运行两个的结果,建议不要同时预约成功三个(上限三个),会收到信息办警告(别问我怎么知道的

[2024-08-30 16:25:11,700 - root - INFO - 14560 - 6072] 江湾体育馆排球场1号-2024-09-01 08:00 可约, ID为8aecc6ce8d17fc0e018d6d7d88217d51 [2024-08-30 16:25:11,700 - root - INFO - 14560 - 6072] 江湾体育馆排球场1号-2024-09-01 09:00 可约, ID为8aecc6ce8d17fc0e018d6d7d88217d53 [2024-08-30 16:25:11,702 - root - INFO - 14560 - 6072] 正在预定江湾体育馆排球场1号-2024-09-01 08:00

DevTools listening on ws://127.0.0.1:5669/devtools/browser/a268301c-35ad-4b0e-b64b-2f2f85116f4b [2024-08-30 16:25:16,099 - root - INFO - 38776 - 41692] 已预定{} [2024-08-30 16:25:16,101 - root - INFO - 38776 - 41692] 江湾体育馆排球场1号-2024-09-01 08:00 可约, ID为8aecc6ce8d17fc0e018d6d7d88217d51 [2024-08-30 16:25:16,102 - root - INFO - 38776 - 41692] 江湾体育馆排球场1号-2024-09-01 09:00 可约, ID为8aecc6ce8d17fc0e018d6d7d88217d53 [2024-08-30 16:25:16,103 - root - INFO - 38776 - 41692] 正在预定江湾体育馆排球场1号-2024-09-01 09:00

DevTools listening on ws://127.0.0.1:5695/devtools/browser/ea1e3cc6-67aa-4300-9632-8370e408cb8a Successfully retrieved valid text: 持之以恒 Successfully retrieved captcha results: {'该': {'left': 129, 'top': 15}, '恒': {'left': 274, 'top': 89}, '之': {'left': 42, 'top': 134}, '以': {'left': 117, 'top': 130}, '持': {'left': 190, 'top': 97}} Successfully retrieved valid text: 朝夕不倦 Verification passed! Successfully retrieved captcha results: {'不': {'left': 250, 'top': 116}, '朝': {'left': 137, 'top': 58}, '夕': {'left': 179, 'top': 67}, '倦': {'left': 66, 'top': 72}} [0830/162525.447:INFO:CONSOLE(648)] "Uncaught TypeError: $(...).combobox is not a function", source: https://elife.fudan.edu.cn/js/system.js (648) [2024-08-30 16:25:28,816 - root - INFO - 14560 - 6072] 已预定{'09-01-08:00': '8aecc6ce90ae440c0191a263a1032710'} [2024-08-30 16:25:28,817 - root - INFO - 14560 - 6072] {'09-01-08:00': '8aecc6ce90ae440c0191a263a1032710'} [2024-08-30 16:25:28,819 - root - INFO - 14560 - 6072] 09-01-08:00 Verification passed! [2024-08-30 16:25:29,672 - root - INFO - 14560 - 6072] 邮件发送成功! [0830/162529.768:INFO:CONSOLE(648)] "Uncaught TypeError: $(...).combobox is not a function", source: https://elife.fudan.edu.cn/js/system.js (648) [2024-08-30 16:25:30,003 - root - INFO - 14560 - 6072] 已预定{'09-01-08:00': '8aecc6ce90ae440c0191a263a1032710', '09-01-09:00': '8aecc6ce90ae440c0191a263b1e42712'} [2024-08-30 16:25:32,793 - root - INFO - 38776 - 41692] 已预定{'09-01-08:00': '8aecc6ce90ae440c0191a263a1032710', '09-01-09:00': '8aecc6ce90ae440c0191a263b1e42712'} [2024-08-30 16:25:32,794 - root - INFO - 38776 - 41692] {'09-01-08:00': '8aecc6ce90ae440c0191a263a1032710', '09-01-09:00': '8aecc6ce90ae440c0191a263b1e42712'} [2024-08-30 16:25:32,794 - root - INFO - 38776 - 41692] 09-01-09:00 [2024-08-30 16:25:33,643 - root - INFO - 38776 - 41692] 邮件发送成功! [2024-08-30 16:25:33,993 - root - INFO - 38776 - 41692] 已预定{'09-01-08:00': '8aecc6ce90ae440c0191a263a1032710', '09-01-09:00': '8aecc6ce90ae440c0191a263b1e42712'}

cocoILoveYoucoco commented 2 weeks ago

如果用系统约的话,一个账号只能约2个的哈哈哈,所以超过2个就···

cocoILoveYoucoco commented 2 weeks ago

stage的时间,一个时间就表示要预约的这个时段的起始时间是不?比如你预约8点和9点的场就只需要在stage输入8:00和9:00就可以

MinhZou commented 2 weeks ago

是的,08:00和09:00,和系统的方式对应。 现在只能约两个了啊,那我的是老黄历了

cocoILoveYoucoco commented 2 weeks ago

谢谢解答!!

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Minhao @.> 发送时间: 2024年8月30日 17:46 收件人: MinhZou/FudanCourtReservation @.> 抄送: cocoILoveYoucoco @.>, Author @.> 主题: Re: [MinhZou/FudanCourtReservation] 求问为什么总是出现ssl连接问题 (Issue #3)

是的,08:00和09:00,和系统的方式对应。 现在只能约两个了啊,那我的是老黄历了

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>