How do I use Curl to send an HTTP header?

To use Curl to send an HTTP header, you can use the -H or --header option followed by the header you want to send.

Here's a basic format:

curl -H "Header-Name: Header-Value" URL

For instance, if you want to send a User-Agent header to http://example.com, you would use the following command:

curl -H "User-Agent: MyUserAgent" http://example.com

You can also send multiple headers by using the -H option multiple times:

curl -H "Header-Name1: Header-Value1" -H "Header-Name2: Header-Value2" URL

Here's an example with multiple headers:

curl -H "User-Agent: MyUserAgent" -H "Accept-Language: en-US" http://example.com

In this example, the User-Agent header is set to MyUserAgent and the Accept-Language header is set to en-US.

Remember to replace Header-Name with the name of the HTTP header you want to send (like User-Agent or Accept-Language) and Header-Value with the value of the HTTP header (like MyUserAgent or en-US). Also, replace URL with the URL of the website you want to send the HTTP headers to.

Note: The headers are case-insensitive so writing user-agent instead of User-Agent will work the same.

Related Questions

Get Started Now

WebScraping.AI provides rotating proxies, Chromium rendering and built-in HTML parser for web scraping
Icon