
Teach you how to use cURL with proxy IP by hand
Web developers know that sometimes it is easy to request a website directly and get shut down. At this time to find a reliable proxy IP is like to request a cloak of invisibility, especially when doing data collection or batch testing. Today, how to use cURL nagging this tool with the proxy, by the way, our own ipipgo proxy service.
Don't be sloppy with your preparations.
First, make sure you have the latest version of cURL installed on your computer, and at the command line hit a
curl --version
You can see it. If you don't have it, go to the official website and download an installer, remember to choose the version with SSL support. Then go to the ipipgo website and register an account, they have a huge pool of proxy IPs and new users can whore out trial packages.
Three Steps to Real-World Configuration
Here is a chestnut, suppose you want to use HTTP proxy, ipipgo gives the connection information: 111.222.33.44:8000, the account password is user123 and pass456. dislike the parameters directly in the command:
curl -x http://user123:pass456@111.222.33.44:8000 https://目标网站.com
See?-x parameteris the key to setting up the proxy, in the formatProtocol://Username:Password@IP:PortIf you are using a SOCKS5 proxy, just replace the http at the beginning with socks5. If you're using a SOCKS5 proxy, just replace the http at the beginning with socks5.
Parameter Setting Tips
| parameters | corresponds English -ity, -ism, -ization | Usage Scenarios |
|---|---|---|
| -proxy-anyauth | automatic forensics | Use when you are not sure of the authentication method |
| -proxy-header | Customized request headers | When you need to disguise your browser |
| -connect-timeout | timeout setting | Anti-jamming is a must |
Common pitfalls QA
Q: Why does it return a 407 error?
A: Nine times out of ten, the account password is typed wrong, or IP is blocked. Go to ipipgo background check the proxy status, their family IP survival rate of 98% it.
Q: How do I test if the proxy is working?
A: No proxy access first
curl https://api.ipipgo.com/ip
Take a look at the local IP and run it again with a proxy to compare the results.
Q: What should I do if I encounter an SSL certificate error?
A: Try adding a-kParameters skip authentication, but don't do this in a formal environment. The proper way to do it is to ask ipipgo's tech support to switch you to a proxy package that supports HTTPS.
Advanced Player Configuration
Write the configuration to the.curlrcDocumentation is less work:
proxy = http://user123:pass456@111.222.33.44:8000
connect-timeout = 20
retry = 3
This way you don't have to take a bunch of arguments each time you hit the command. However, if you want to temporarily disable the proxy, remember to add a-noproxy ""Parameters.
Finally, the last nagging, choose the proxy service to look at the right like ipipgo such a professional operation and maintenance team. They not only provide APIs to dynamically obtain IP, but also customized proxy packages, the old driver of the crawler project know how important it is to have a stable IP. If you're still using a free proxy that drops out every three days, hurry up and take a look at the promotional activities on the official website.

