curl 无法下载指定链接的文件

问题描述:

想下载 “https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=sys.pcap”,但是直接使用curl下载时确一直下载的是 ”https://wiki.wireshark.org/SampleCaptures“ 这个网页内容。

curl -O -s https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=sys.pcap

然后使用curl -v 查看详细信息,找出原因:

* Hostname was NOT found in DNS cache
*  Trying 104.25.218.21...
* Connected to wiki.wireshark.org (104.25.218.21) port 443 (#0)
* successfully set certificate verify locations:
*  CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-ECDSA-AES128-GCM-SHA256
* Server certificate:
* subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=ssl380445.cloudflaressl.com
* start date: 2016-12-27 00:00:00 GMT
* expire date: 2017-07-02 23:59:59 GMT
* subjectAltName: wiki.wireshark.org matched
* issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO ECC Domain Validation Secure Server CA 2
* SSL certificate verify ok.

> GET /SampleCaptures?action=AttachFile HTTP/1.1
> User-Agent: curl/7.35.0
> Host: wiki.wireshark.org
> Accept: */*
>

< HTTP/1.1 200 OK
... ...

说明curl请求的地址本身就不对,字符串被截断,至于为什么被截断,我也不知道。

解决方法:

添加引号到url两边,如下:

curl -O -s “https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=sys.pcap”

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容