Kho kiến thức / Setup & usage

Web scraping with proxy IPs

Which IPs to use, rotation, rate limits and retries, with Python / Node.js / Scrapy code.

When collecting public web data (price monitoring, product info, search results, sentiment), too many requests from one IP get rate-limited, challenged with captchas or blocked. Spreading requests across several proxy IPs is the simplest and most effective fix.

Which IPs to use

  • Datacenter / shared IPv4: cheap and fast, good for lightly protected sites and bulk crawling.
  • IPv6: lots of addresses at a low price; best value when the target supports IPv6.
  • Static residential / ISP: look like real users; for e-commerce, social media and other strict sites, or logged-in scraping.
  • Rotating residential: billed by traffic with a new IP automatically; for very large jobs that need a fresh IP per request.
Start with 1–2 IPs to test how the target reacts, then pick the type and quantity. Buy proxy IPs

Rotation: use a pool

In My proxies click Copy all and save the IPs as proxies.txt (host:port:user:pass per line). Your code picks one at random or in turn for each request.

python
import random, time, requests

proxies = [l.strip().split(":") for l in open("proxies.txt") if l.strip()]

def get(url, tries=3):
    for i in range(tries):
        h, port, u, pw = random.choice(proxies)
        p = f"http://{u}:{pw}@{h}:{port}"
        try:
            r = requests.get(url, proxies={"http": p, "https": p}, timeout=15,
                             headers={"User-Agent": "Mozilla/5.0"})
            if r.status_code == 200:
                return r.text
            if r.status_code in (403, 429):
                time.sleep(2 ** i)  # rate-limited: switch IP and back off
        except requests.RequestException:
            pass
    return None

for url in ["https://example.com/page/1", "https://example.com/page/2"]:
    html = get(url)
    time.sleep(random.uniform(1, 3))  # random pause between requests

Node.js

js
import { ProxyAgent, fetch } from "undici";
import { readFileSync } from "node:fs";

const pool = readFileSync("proxies.txt", "utf8").trim().split("\n").map((l) => {
  const [h, port, u, p] = l.trim().split(":");
  return new ProxyAgent(`http://${u}:${p}@${h}:${port}`);
});
let i = 0;
const res = await fetch("https://example.com", { dispatcher: pool[i++ % pool.length] });
console.log(res.status);

Scrapy

Set proxy in the Request meta; Scrapy's built-in HttpProxyMiddleware handles the login:

python
yield scrapy.Request(url, meta={"proxy": "http://user:pass@1.2.3.4:8000"})

# settings.py
DOWNLOAD_DELAY = 1.5
CONCURRENT_REQUESTS_PER_DOMAIN = 4
RETRY_HTTP_CODES = [403, 429, 500, 502, 503]
AUTOTHROTTLE_ENABLED = True

Don't want to manage IPs? Use the scraping API

Create a key on the Reseller API page and call POST /api/v1/scrape: we fetch the page through our own proxy IPs, with an optional country and CSS selector. 20 free a day, then $0.01 each. Try it by hand first in Data → Web scraper.

bash
curl -X POST https://ip.naian.edu.kg/convex-site/api/v1/scrape \
  -H "Authorization: Bearer iph_YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","country":"US","selector":"h1"}'

Getting blocked less

  • Keep it slow: at most about 1 request per second per IP, with random pauses.
  • Concurrency = number of IPs × per-IP concurrency; don't push all traffic through a few IPs.
  • On 403 / 429 / captchas: switch IP and retry with exponential backoff instead of hammering.
  • Send normal headers (User-Agent, Accept-Language); for logged-in sites keep one account on one IP.
  • Use IPs from the target site's country to avoid extra checks and redirects.
  • For JS-heavy pages use Playwright / Puppeteer with --proxy-server, and pass the login via page.authenticate or the context's proxy option.

Stay compliant

Collect only public data, follow the site's terms and robots.txt, don't collect personal or restricted data, and don't flood sites with traffic. Misuse leads to suspension; see Acceptable use.

Connection problems? See Proxy not working?, or copy ready-filled code from the setup guides.

Còn thắc mắc? Gửi ticket, hỗ trợ sẽ trả lời sớm.Liên hệ hỗ trợ →