
Teach you how to use curl to download a file when hanging proxy
Engaged in network development know, with curl under the file like eating and drinking water as usual. But when it comes to the target site to limit the number of IP access, that's a bad thing! This time the proxy IP is a lifesaver. Today we use our own product ipipgo proxy service, teach you how to play with the command line download.
curl -x http://username:password@proxy.ipipgo.cn:8080 -O http://example.com/file.zip
The above line of code looks simple, but actually hides a couple ofPitfalls to watch out forThe special symbols in the proxy address should be escaped, the connection timeout is recommended to set more than 5 seconds, and remember to add a -limit-rate speed limit for large file downloads. By the way, with ipipgo's proxy service, their technical documents say that support http/https/socks5 three protocols, the actual test down http protocol compatibility is the best.
Proxy IP parameter setting tips
A lot of newbies get stuck on the agent authentication piece, so here's a universal template:
curl -U "user:pass" --proxy http://proxy.ipipgo.cn:8888 -L http://target.com
Note that the -U parameter is specialized in handling proxies that require account passwords, which is safer than writing them directly in the URL. When you encounter 302 jumps, you must add the -L parameter to track properly. ipipgo's exclusive proxy package, it is recommended that you use the fixed IP mode, the stability is a big step higher than the dynamic pool.
| problematic phenomenon | prescription |
|---|---|
| slow download speed | Switching ipipgo's BGP line |
| high frequency of disconnection | Increase the value of the -max-time parameter. |
| certificate error | Add the -k parameter to skip authentication |
Automatic IP switching
When you need to download in bulk, it's stupid to change proxies manually. Here's an example shell script that works with the ipipgo API to dynamically get proxies:
! /bin/bash
for i in {1..10}
! /bin/bash for i in {1..10}
proxy=$(curl -s ipipgo.com/api/get_proxy)
curl -x $proxy -O "http://site.com/file_$i.zip"
sleep 5
done
The key point is to pull new proxies from ipipgo's interface before each request, and the interval should not be too short (more than 5 seconds is recommended). Their enterprise package supports 10 IP changes per second, and the basic version is enough for the average user.
Frequently Asked Questions QA
Q: What should I do if the proxy connection times out?
A: Check the firewall settings first, and then use the curl -v parameter to see the detailed handshaking process. ipipgo's console has real-time connection logs, which can pinpoint the problem node.
Q: What should I do if the download is interrupted in the middle?
A: Continue the transfer with the -C - parameter, for example:
curl -x ipipgo proxy address -C - -O bigfile.iso
Q: How can I verify if the agent is in effect?
A: First access the IP detection interface of ipipgo:
curl -x proxy address http://api.ipipgo.com/myip
Finally, to say a word of heart, the choice of proxy service providers to look at the response speed and IP quality. ipipgo's nodes have three major carriers + offshore lines, measured download speed can run full 100 megabytes of bandwidth. New users remember to register to receive a free trial package, enough for you to toss a good while.

