
Teach you how to use Fetch with proxy IPs
Brothers engaged in data collection or interface testing should have encountered the situation of IP blocked, right? This time we have to rely on proxy IP to save the life. Let's nag today how to use Fetch this tool with the proxy IP to work, to ensure that you can get started after reading the operation.
First to the white popularize: Fetch is the browser comes with the data request tool, than the traditional Ajax is not half a star. However, it is easy to use it directly to send a request to the target site to block the IP, this time it will have to beact as an agent for sb.to hide the real address.
// Example of a basic fetch request
fetch('target url')
.then(response => response.json())
.then(data => console.log(data));
Proxy IP real-world configuration tips
Here's the kicker! Adding agents to fetch actually has a trick. The key is to use theagent parametersto specify the proxy server. Here we recommend using ipipgo's proxy service, their TK line is especially good for high frequency requests.
const HttpsProxyAgent = require('https-proxy-agent');
const proxyAgent = new HttpsProxyAgent('http://用户名:密码@proxy-ip:port');
fetch('Target URL', { agent: proxyAgent })
.then(response => response.text());
Note that here we need to use the package https-proxy-agent, load package commandnpm install https-proxy-agentDon't miss it. ipipgo's proxy supports HTTP/HTTPS/Socks5 protocols, and it is recommended to use Socks5 protocol to be more secure.
Agent selection strategy for different scenarios
| Business Type | Recommended Agent Type | Monthly fee reference |
|---|---|---|
| data acquisition | Dynamic Residential (Business) | 9.47 Yuan/GB |
| interface testing | Static homes | 35RMB/IP |
| Long-term mandate | TK Line | Customized Quotation |
Special reminder: to do such high-frequency crawler request, must be selected dynamic residential agent, ipipgo dynamic IP pool every 5-10 minutes automatically change the IP, pro-test effective anti-seizure.
The experience of stepping into the pit
1. EncounterECONNRESET errorDon't panic, it's likely that the proxy IP is hanging. At this time to check the ipipgo console usage statistics, to confirm whether the IP expires or is the target station pulled black!
2. Remember to set the timeout parameter for the request timeout, which is recommended to be no more than 30 seconds. Code example:
const controller = new AbortController();
setTimeout(() => controller.abort(), 30000);
fetch(url, {
signal: controller.signal,
agent: proxyAgent
});
Frequently Asked Questions
Q: What should I do if the proxy IP is unstable?
A: Priority check the network environment, if you are using ipipgo's residential agent, it is recommended to switch to their cross-border line, the delay can be reduced to 60% or more!
Q: What if I need to change IP frequently?
A: In the background of ipipgo to open the automatic rotation mode, support for switching by the number of requests or time intervals, the enterprise version of the user can also customize the switching strategy
Q: Will the cost be high?
A: Depends on the amount of use, if you do testing, choose the standard version of Dynamic Residential, more than 7 yuan 1 G enough to use for a long time. It's more cost-effective for large enterprises to go directly to a customized program
Choose the right agent to save half the worry
Finally, I'd like to give you an encore of three of ipipgo's best tricks:
1. Client self-containedIntelligent Route SwitchingAutomatic selection of the fastest node
2. ExclusiveIP Health DetectionFunction to automatically filter invalid proxies
3. SupportMulti-protocol mixingThe account can use HTTP and Socks5 at the same time.
Their API docking documents are written in detail, and they also have specialized technical support. Recently, new users can also get a free trial of 500MB of traffic for the first order, specifically go to the official website to take a look at know.

