python - 请求问题(获取)
问题描述
我在向网站发送请求时遇到问题。我正在使用“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
解决方案
我在您提到的网站上尝试了 curl 和 python 的请求库,并提取了所需的内容。确保你的 linux 机器上的 curl 工作正常。如果你愿意,你可以试试下面的简单代码。
import requests
myrequest = requests.get("https://nhentai.net/")
print(myrequest.text)
推荐阅读
- python - 如何根据 Pandas 中的某些列连接列的值?
- javascript - 数组和对象在 console.log {sometimes } 和通过 socket.io 发送时为空
- java - 如何通过点击 Firestore 中的 URL 在 Firebase 存储上上传 2 张图片
- python-3.x - 将字符串数组转换为二维 numpy 数组
- docker - 如何为 2 个单独的 VM 创建 2 个 docker-compose 文件?
- c++ - 为什么 C++23 string::resize_and_overwrite 将操作作为右值调用?
- checkpoint - 检查点 IPS 警报不包含任何信息
- compiler-construction - 如何在 LLVM 中获取 O1、O2、O3 的通行证?
- c# - 如何查询/将数据转换为所需的格式
- python - Tesseract,openCV,python:如何获取句子或同一行文本的边界框?