
Teach you how to use cURL to hang a proxy!
Engaged in network development know, cURL is like a universal toolbox, but to use a good proxy IP this piece really need to pay attention to some of the doorway. Let's start by understanding the core parameters - the-xor-proxyThe two are actually the same thing. For example, to use a socks5 proxy write it like this:
curl -x "socks5://username:password@proxy:port" https://目标网址.com
Here is a pitfall to note, if the proxy server does not require authentication, directly delete the "username:password@" paragraph on the line. When you use ipipgo's proxy, their client will automatically generate the authentication information, so we can just copy and paste it and be done with it.
How to play proxy with different protocols
Now the mainstream protocols on the three, let's take ipipgo supported protocols as a chestnut:
| Protocol type | Example of formatting |
|---|---|
| HTTP | http://ipipgo.com:8080 |
| HTTPS | https://ipipgo.com:443 |
| Socks5 | socks5://ipipgo.com:1080 |
Actual tests have found that some older systems may jerk when using the socks5 protocol. This is a good time to try adding a-proxy-anyauthparameter to let cURL choose its own authentication method.
Troublesome maneuvers in the real world
1. timeout setting: Some agents are slow to respond, plus-m 30parameter, automatically abandoned after 30 seconds
curl -x "http://ipipgo代理地址" -m 30 https://目标网站
2. Retesting mechanism: When encountering unstable proxy IPs, use-Retry 3Auto retry three times
3. debugger: plus-vParameters can see the complete request process, even the proxy handshake process is clearly visible
The pitfalls you're bound to encounter
Certificate error: When using HTTPS proxies, you often encounter SSL certificate problems, so don't panic.-kParameters first skip the validation. However, this is not recommended for formal environments, and it is best to have the proxy service provider provide a formal certificate.
Chinese garbled code: Return data into Martian? At the end of the command add| iconv -f gbk -t utf8, nine times out of ten it will work out.
QA time
Q: Why does access with proxy always timeout?
A: First check whether the proxy IP is alive, with ipipgo client, it is recommended to change the static residential IP, the stability of several grades higher!
Q: How to batch test whether the agent is effective?
A: Write a shell script to call it in a loop, remember to add a timeout parameter, something like this:
for ip in $(cat iplist.txt); do
curl -x "http://$ip" -m 5 -s -o /dev/null https://ipipgo.com/check && echo "$ip available"
done
Why ipipgo?
Speaking from experience with his own home use, theTK LineIndeed powerful. Last time to do cross-border e-commerce data collection, with ordinary proxy 10 requests to have 3 failures, cut to the TK line directly down to 1% below. The price of static residential 35 dollars an IP, do need fixed IP business is quite cost-effective.
Beginners are advised to buy the standard version of the dynamic residential, more than 7 yuan 1 G traffic, the test phase is completely sufficient. To enterprise-level services, then directly on the customized program, their technical support can help adjust the proxy parameters, more than their own toss to save a lot of heartache.
One last tip: when using the ipipgo API to get a proxy, add theformat=curlparameter, the return is directly usable cURL command format, this design is really convenient.

