How to Specify User Agent with cURL

Publikováno: 25.2.2020

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 […]

The post How to Specify User Agent with cURL appeared first on David Walsh Blog.

Celý článek

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!

The user agent may be sent with the -A or --user-agent directives:

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!

The post How to Specify User Agent with cURL appeared first on David Walsh Blog.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace