Answer the question
In order to leave comments, you need to log in
Why does the fetch request return an error after a while?
There is such a script, with the help of puppeteer I open the site and start throwing a fetch request every 30 seconds
setInterval(async () => await updateFiles(page), 30000)
const updateFiles = async page => {
const data = await page.evaluate(async () => {
const request = await fetch(`https://site.com`)
const data = await request.text()
return data
})
global.$ = cheerio.load(data, { decodeEntities: true })
const results = handler(data);
console.log(results.length)
await db.loadFiles(results, b)
}
Answer the question
In order to leave comments, you need to log in
5xx errors - server errors.
Specifically 503 - Service Temporarily Unavailable - the service is temporarily unavailable.
The server sends you to hell. Most likely there is a protection against frequent repetitive requests. Either the server crashes, but that's unlikely.
You can try to randomize the query frequency and change the headers and user agent. But he doesn't know what will help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question