我无法从WikiMedia网站下载任何内容,如维基百科和维基引用,使用curl。
当我尝试的时候,我得到:
~$ /usr/bin/curl -v "http://en.wikipedia.org/wiki/Celsius"
* Trying 2620:0:863:ed1a::1...
* TCP_NODELAY set
* Connected to en.wikipedia.org (2620:0:863:ed1a::1) port 80 (#0)
> GET /wiki/Celsius HTTP/1.1
> Host: en.wikipedia.org
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Fri, 19 May 2017 22:09:49 GMT
< Server: Varnish
< X-Varnish: 350654144
< X-Cache: cp4017 int
< X-Cache-Status: int
< Set-Cookie: WMF-Last-Access=19-May-2017;Path=/;HttpOnly;secure;Expires=Tue, 20 Jun 2017 12:00:00 GMT
< Set-Cookie: WMF-Last-Access-Global=19-May-2017;Path=/;Domain=.wikipedia.org;HttpOnly;secure;Expires=Tue, 20 Jun 2017 12:00:00 GMT
< X-Client-IP: 2605:a601:1127:7d00:35a2:5040:e002:9949
< Location: https://en.wikipedia.org/wiki/Celsius
< Content-Length: 0
< Connection: keep-alive
<
* Curl_http_done: called premature == 0
* Connection #0 to host en.wikipedia.org left intact也没有实际内容。同样的url可以在wget中很好地下载。我也可以下载其他网站与curl。它是curl和WikiMedia网站的结合(维基百科,维基引用,.)导致了这一切。
我用的是Ununtu伙伴17.04。我的卷发版本是:
/usr/bin/curl --version
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy PSL 有什么问题吗?
发布于 2017-05-19 22:31:14
在chrome和其他浏览器中,您可以选择以curl的形式获取请求。
启动开发人员工具,刷新页面,右键单击“网络”选项卡下的第一个链接。右击它,然后“复制”,然后“复制为卷曲”。
有效的示例:
curl 'https://en.wikipedia.org/wiki/Celsius' -H 'pragma: no-cache' -H 'dnt: 1' -H 'accept-encoding: gzip, deflate, sdch, br' -H 'accept-language: en-US,en;q=0.8,ro;q=0.6,la;q=0.4' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/531.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/511.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'cache-control: no-cache' -H 'authority: en.wikipedia.org' -H 'WMF-Last-Access=19-May-2017; WMF-Last-Access-Global=19-May-2017' --compressed卷曲版本:
curl 7.51.0命令不能工作的原因是需要指示cURL遵循重定向(您还会注意到所提供的示例中的302 ):
curl -L http://en.wikipedia.org/wiki/Celsiushttps://stackoverflow.com/questions/44079830
复制相似问题