首页 > 解决方案 > 请求问题(获取)

问题描述

我在向网站发送请求时遇到问题。我正在使用“hentai”库在 Python 上使用 nhentai API 制作一个有用的电报机器人(请不要判断)。为什么在 Linux (Ubuntu) 上会出现此错误?

:~$ curl -v https://nhentai.net
* Expire in 0 ms for 6 (transfer 0x55c3a8516530)
  ...
* Expire in 9 ms for 1 (transfer 0x55c3a8516530)
*   Trying 104.27.195.88...
* TCP_NODELAY set
* Expire in 149985 ms for 3 (transfer 0x55c3a8516530)
* Expire in 200 ms for 4 (transfer 0x55c3a8516530)
* Connected to nhentai.net (104.27.195.88) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to nhentai.net:443
* Closing connection 0
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to nhentai.net:443

标签: pythonpython-3.xsslpython-requestsopenssl

解决方案


我在您提到的网站上尝试了 curl 和 python 的请求库,并提取了所需的内容。确保你的 linux 机器上的 curl 工作正常。如果你愿意,你可以试试下面的简单代码。

import requests

myrequest = requests.get("https://nhentai.net/")

print(myrequest.text)

推荐阅读