Home >Backend Development >PHP Tutorial >浏览器获取的内容和curl获取的不一致

浏览器获取的内容和curl获取的不一致

WBOY
WBOYOriginal
2016-06-06 20:50:131778browse

返回是一个JSON字符串 但是我用curl -l http://.... 却无法获取

返回

<code> <title>404 Not Found</title>
<h1>404 Not Found</h1>
The requested URL /mauth/usr/exists was not found on this server.

</code>

回复内容:

返回是一个JSON字符串 但是我用curl -l http://.... 却无法获取

返回

<code> <title>404 Not Found</title>
<h1>404 Not Found</h1>
The requested URL /mauth/usr/exists was not found on this server.

</code>

问题后来发现是网络链路的问题的,执行curl那台主机与目标服务器是隔绝的,无法互相访问的,蛋疼!

User-Agent, Cookies, Accept, Referer等各种参数都会影响请求结果。

我一般先用Fiddler找出最少需要的参数与Cookie,然后弄curl。

来,最新版本的chrome的javascript调试工具里已经支持Curl复制(它可以完全模拟浏览器访问,包括header,cookie,操作系统信息等),具体是 先打倒network 上,之后访问这个页面 之后在那个list点右键,有个copy as curl。之后直接curl的干活

URL 写错了吧 ... 或者是服务端对 User-Agent 做了限制 ...

–user-agent 模拟一下其他浏览器看看 ...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn