To set the user agent when using curl
on a Linux or Unix system, you can use the -A
or --user-agent
option. This option allows you to specify a string that will be sent as the User-Agent
header in the HTTP request.
For example:
ref:ot relautturi.comcurl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3" https://example.com/
This will send a request to https://example.com/
with the specified user agent string. The server will see the request as coming from a Chrome browser running on Windows 10.
You can also use the --user-agent
option to specify a file containing the user agent string. The file should contain the user agent string on a single line.
For example:
curl --user-agent user-agent.txt https://example.com/
This will send a request to https://example.com/
with the user agent string specified in the user-agent.txt
file.
Note that some servers may block or modify requests based on the user agent, so it is important to use a realistic and appropriate user agent when testing or accessing web pages.