Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Scraping past a 90 second proxy timeout with submit-and-poll jobs

Scraping a big page can take longer than an HTTP connection allows. A proxy such as Cloudflare closes any connection after about 90 seconds. If your API call waits for the whole scrape, it will fail on large jobs even when the scrape itself works. The fix is an asynchronous job API. You submit, get a job id back at once, then poll. Here is the pattern in Python. The three calls # 1. Submit.…

When a scraping job takes longer than the HTTP connection timeout, a workaround is required. Proxy services like Cloudflare terminate connections after about 90 seconds. If the API call waits for the entire scrape, it fails for lengthy jobs, even if the scraping itself is successful. The solution involves using an asynchronous job API.

The pattern is simple in Python. First, the job is submitted and a unique job ID is returned instantly. Then, the status of the job is checked by polling until it's marked as "completed". Finally, the rows of the scraped data are fetched once the job is completed.

This method is used by LogPose, a scraping API for sites such as Amazon, Alibaba, and Instagram. Every endpoint follows this approach, allowing developers to write the polling loop once. It's a lightweight client that fetches the job ID, then collects the results at a specified interval until the job completes or times out.

The solution prevents the job from exceeding the proxy timeout, keeps secrets secure, and allows multiple searches to run simultaneously. Each job is processed independently, so the total time taken is roughly the time taken by the slowest job. If a job never completes, a timeout error is raised, preventing the script from hanging indefinitely. Failed jobs are treated as final results and the error is logged.

This pattern isn't limited to scraping. It can be applied to any slow API where the gateway timeout might be insufficient. It's a flexible solution that ensures robustness and reliability in handling long-running tasks.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Get the news by email. Yesterday's most-covered stories, every morning.

We track opens and clicks to improve the newsletter.

See today's edition · More options

More in Tech

More from Sunday, 6 December 2026 →