curl指定代理
Over the years I've shared how to perform a number of actions with cURL: how to send POST data, how to retrieve headers, follow redirects, check GZIP encoding, and more. Another useful cURL directive is sending the user agent, as some servers respond with different content or headers depending on the user agent. Let's have a look at how easy it is to send the user agent with cURL!
多年来,我分享了如何使用cURL执行许多操作: 如何发送POST数据 , 如何检索标头 , 遵循重定向 ,检查GZIP编码等等。 另一个有用的cURL指令是发送用户代理,因为某些服务器根据用户代理使用不同的内容或标头进行响应。 让我们看一下使用cURL发送用户代理有多么容易!
The user agent may be sent with the -A
or --user-agent
directives:
可以使用-A
或--user-agent
指令发送用户代理:
curl -A "MY-USER-AGENT" https://www.whatismybrowser.com/detect/what-is-my-user-agent
# .... Your user agent is: `MY-USER-AGENT` ...
Luckily we don't rely on user agent strings as much as we did in the early days of the web, but we'd be naive to assume that they no longer modify the output of all websites!
幸运的是,我们不像早期的网络那样依赖用户代理字符串,但是我们天真地假设它们不再修改所有网站的输出!
翻译自: https://davidwalsh.name/how-to-specify-user-agent-with-curl
curl指定代理