cURL is a small *nix utility to perform network requests.

This is a quick cheat sheet on how cURL can be used for web scraping or any other cases when you need to appear as sending web request from another ip address.

cURL set proxy

Setting proxy URL for cURL:

curl --proxy

Shortcut for --proxy option is -x, so this is the exact equivalent:

curl -x

cURL supports http, https, and socks proxies.

For a simple proxy checker script, powered by cURL and available in your terminal, see this post.

Setting headers in cURL

it is always a good idea to set browser user-agent AND proxy:

curl --proxy '' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36'

Send POST request with JSON in cURL

curl -X POST -H 'Content-Type: application/json'
   -d '{"login":"my_login","password":"my_password"}'

note how -X option is used to specify POST request. Do not be confused, lower case -x is used to set proxy, uppercase -X is used to specify HTTP method!

Get your machine ip address via cURL:


Sample output:

{"ip":"","country":"TR","asn":{"asnum":35984,"org_name":"Superonline A.S."},"geo":{"city":"Antalya","region":"07","region_name":"Antalya","postal_code":"07070","latitude":36.2409,"longitude":30.3219,"tz":"Europe/Istanbul","lum_city":"antalya","lum_region":"07"}}%   

of course, the same trick can be used to see the proxy location:

curl -x http://login:pw@proxyhost:port

View HTTP response code and more details, in cURL

curl -v 

-v flag means verbose, so it outputs a lot of useful data along with response

Sample output:

*   Trying
* Connected to ( port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject:
*  start date: Oct 12 00:00:00 2022 GMT
*  expire date: Oct 18 23:59:59 2023 GMT
*  subjectAltName: host "" matched cert's ""
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x125811400)
> GET /myip.json HTTP/2
> Host:
> user-agent: curl/7.79.1
> accept: */*
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200 
< server: nginx
< date: Mon, 12 Dec 2022 16:21:47 GMT
< content-type: application/json; charset=utf-8
< content-length: 296
< cache-control: no-store
< access-control-allow-origin: *
* Connection #0 to host left intact
{"ip":"","country":"TR","asn":{"asnum":35984,"org_name":"Superonline A.S."},"geo":{"city":"Antalya","region":"07","region_name":"Antalya","postal_code":"07070","latitude":36.2409,"longitude":30.3219,"tz":"Europe/Istanbul","lum_city":"antalya","lum_region":"07"}}%    

Generate Python web scraper from cURL

Convering cURL to Python is possible using ScrapeNinja cURL converter will do even more - not only it will convert your cURL to Python Requests code, it will also leverage special scraping cloud API which will automatically:

  1. Use rotating residential proxies (and you can choose multiple proxy locations)
  2. Have TLS fingerprint of Chrome browser instead of TLS fingerprint of Python which helps to unblock a lot of websites
  3. Leverage smart retry strategies