curl 无法从 url 获取完整响应
我在centos 5.5中使用curl,并像下面这样使用curl来从url获取响应:
curl 7.21.2 (x86_64-unknown-linux-gnu) libcurl/7.21.2 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM SSL libz
http://www.51buy .com/portal.html,我可以得到响应,但它不完整,例如你找不到“934”,但“934”确实在该html源代码上。
另一方面,在我的Windows上,我使用了如下所示的curl版本
curl 7.21.2 (i386-pc-win32) libcurl/7.21.2 OpenSSL/0.9.8o zlib/1.2.5 libidn/1.18 libssh2/1.2.7 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS IDN Largefile NTLM SSL SSPI libz
并获得相同的url,它可以获得完整的响应。
谁能给我一些线索来帮助我解决这个问题? 先感谢您。
i use curl in centos 5.5 and curl like below to get the response from the url:
curl 7.21.2 (x86_64-unknown-linux-gnu) libcurl/7.21.2 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM SSL libz
http://www.51buy.com/portal.html, and i can get the response but it's not complete, for example you can not find '934', but '934' is really on that html source code.
on the other hand on my windows, i used the curl version like below
curl 7.21.2 (i386-pc-win32) libcurl/7.21.2 OpenSSL/0.9.8o zlib/1.2.5 libidn/1.18 libssh2/1.2.7 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS IDN Largefile NTLM SSL SSPI libz
and to get the same url, it can get the complete response.
can anyone give me some clue to help me to resolve the issue?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大多数情况下,当您收到不同的响应时,这是因为该网站尝试根据您的用户代理或类似代理执行不同的操作。
为了伪造这一点,找出浏览器发送的确切请求,然后尝试尽可能模仿该请求通常是一种成功的方法。
在这种情况下,由于Windows版本的curl似乎可以工作,您可以尝试将linux情况下的用户代理设置为看起来像Windows的curl版本...
由于您没有包含任何特定的协议详细信息,我们可以不要进一步猜测实际内容。
Most often when you get different responses, it is because the site tries to do different things depending on your user-agent or similar.
To counterfeit that, figuring out the exact request your browser sends and then trying to mimic that as closely as possible is often a winning approach.
In this case, since the windows version of curl seems to work, you could try to set the user-agent in the linux case to look like the windows curl version...
As you didn't include any specific protocol details, we can't guess any further about the actual contents.