
How to play with proxy IP data? Hands-on teaching you to disassemble the JSON format
engaged in crawling friends understand that many agents now return data are JSON format. This thing looks like a book, in fact, to dismantle than peeling oranges is also simple. Let's take ipipgo's API response as a chestnut, their return data is long like this:
{
"code": 200,
"data": [
{
"ip": "45.88.123.88",
"port": 8866, "expire_time": "2024-08-01 23:59",
"expire_time": "2024-08-01 23:59:59"
},
{
"ip": "103.88.45.12",
"port": 3128, { "expire_time": "expire_time": "2024-08-01 23:59:59" }, { "ip": "103.88.45.12", { "port": "3128,
"expire_time": "2024-08-02 00:30:00"
}
]
}
focus ondata arrayThe address, port, and expiration time of every object, every IP address, and every IP address are all here. With Python, the json library is three lines of code away:
import json
resp = 'the JSON data above'
proxy_list = json.loads(resp)['data']
Hands-on teaching: from getting the IP to actually using it
Don't just know how to parse without using it! Assuming we've got a list of proxies via the ipipgo API, we need to verify the validity. Here is a universal validation script:
import requests
for proxy in proxy_list:
try: response = requests.get('')
response = requests.get('http://httpbin.org/ip',
proxies={'http': f"{proxy['ip']}:{proxy['port']}"}, timeout=5), timeout=5)
timeout=5)
print(f "Available IPs: {proxy['ip']}:{proxy['port']}")
except.
print(f "Failed IP: {proxy['ip']}")
This script quickly sifts out IPs that work. watch forSet timeout to 5 secondsMost appropriate, too short to misjudge, too long to delay.
Why do you recommend ipipgo's services?
Having used seven or eight proxy providers, it's not for nothing that I ended up locking up ipipgo. Three of their stunts are particularly top notch:
1. The protocol family bucket: HTTP/HTTPS/Socks5 are fully supported, unlike some platforms that only open half the door!
2. Effortless extraction: The API is designed to be user-friendly and the return format is standardized.
3. Packages are not fraudulent: Dynamic residential minimum 7 more than 1G traffic, do data collection absolutely affordable!
| Package Type | Applicable Scenarios | prices |
|---|---|---|
| Dynamic residential (standard) | Daily data collection | 7.67 Yuan/GB |
| Dynamic Residential (Business) | High-frequency operational requirements | 9.47 Yuan/GB |
| Static homes | Long-term fixed IP requirements | 35 yuan/month |
Frequently Asked Questions
Q: Do I have to write code to parse JSON data?
A: Not absolutely! It's possible to parse manually with a tool like Postman, but it's still more efficient to write scripts for batch processing.
Q: How do I know if the IP can be used after API extraction?
A: ipipgo's client comes with a detection function, or run through the verification script taught above.
Q: Do I choose a dynamic or static package?
A: Depends on the business scenario. It is more cost-effective to choose dynamic for crawlers, and static residential for those who need to log in for a long time.
Finally, to be honest, the proxy IP thing is three parts by tools and seven parts by service providers. ipipgo'sTK Linerespond in singingCloud Server IntegrationIt is really fragrant, especially brothers doing overseas business, cross-border line can save a lot of trouble. New users are advised to use the dynamic standard version to try the water first, and then switch to the enterprise version after a large amount of use, so that the most cost-effective.

