命令行是:
$ curl -v -k "https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&ids=Q111" |
> jq .
我使用WSL2来输入上面的命令。显示错误。
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 103.102.166.224:443...
* Connected to www.wikidata.org (103.102.166.224) port 443 (#0)
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* ALPN, offering h2
* ALPN, offering http/1.1
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: /etc/ssl/certs
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
0 0 0 0 0 0 0 0 --:--:-- 0:01:59 --:--:-- 0* TLSv1.0 (OUT), TLS header, Unknown (21):
} [5 bytes data]
* TLSv1.3 (OUT), TLS alert, decode error (562):
} [2 bytes data]
* error:0A000126:SSL routines::unexpected eof while reading
0 0 0 0 0 0 0 0 --:--:-- 0:02:00 --:--:-- 0
* Closing connection 0
curl: (35) error:0A000126:SSL routines::unexpected eof while reading
我用过sudo apt update
和sudo apt upgrade
,curl -V
显示curl的版本和openssl的版本:
curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.14
Release-Date: 2022-01-05
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets zstd
我也在Cygwin上输入命令。它显示不同的错误:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 103.102.166.224:443...
* Connected to www.wikidata.org (103.102.166.224) port 443 (#0)
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
0 0 0 0 0 0 0 0 --:--:-- 0:00:19 --:--:-- 0* Recv failure: Connection was reset
* schannel: failed to receive handshake, SSL/TLS connection failed
0 0 0 0 0 0 0 0 --:--:-- 0:00:19 --:--:-- 0
* Closing connection 0
* schannel: shutting down SSL/TLS connection with www.wikidata.org port 443
* Send failure: Connection was reset
* schannel: failed to send close msg: Failed sending data to the peer (bytes written: -1)
curl: (35) Recv failure: Connection was reset
我该怎么解决呢?
1条答案
按热度按时间jjjwad0x1#
首先验证curl是否生成任何数据。或许:
然后检查文件。您的URL可能不正确。
您还可以考虑使用jsonlint检查结果文件。