Replies: 3 comments 5 replies
-
app/crawlee:start: /Users/ha/Codes/arcteryx-crawlee/node_modules/.pnpm/@crawlee[email protected]/node_modules/@crawlee/memory-storage/fs/key-value-store/fs.js:72 |
Beta Was this translation helpful? Give feedback.
-
@B4nan Bro, repeating requests makes sense, for example, I want to know if a certain product is restocked. I plan to request every five minutes. What should I do in this scene |
Beta Was this translation helpful? Give feedback.
-
Your problem is most likely the manual storage purge, both of your crawler instances use the same default storages, but you wipe them by hand with the For this use case, I would suggest you disable storage persistence completely: import { Configuration, PlaywrightCrawler, ProxyConfiguration } from 'crawlee'
import { scheduleJob } from 'node-schedule'
import { router } from './routes'
const createCrawler = () => {
const config = new Configuration({ persistStorage: false }) // <== added `persistStorage: false` here
const crawler = new PlaywrightCrawler(
{
proxyConfiguration: new ProxyConfiguration({ proxyUrls: [p] }),
requestHandler: router,
maxRequestsPerCrawl: 50,
maxRequestRetries: 0,
},
config,
)
return crawler
}
const taskRun = async () => {
const crawler = createCrawler()
const linkList = ['https://github.com/xx1', 'https://github.com/xx2']
await crawler.run(linkList).finally(() => {
// void purgeDefaultStorages() // <== now you don't need this
})
}
scheduleJob('* 0-4 * * *', async () => {
await taskRun()
})
scheduleJob('*/2 5-10 * * *', async () => {
await taskRun()
}) I would keep separate crawler instances here, since you might run them both at the same time, you can't really share the state of them. |
Beta Was this translation helpful? Give feedback.
-
I am a newbie in crawlee. I need to monitor some fixed links. Often, node-schedule cannot continue because of an error in a task. The following is my code,Should I do something?
Also, can you tell me what is the difference between createCrawler for each task and using a global crawler?
Beta Was this translation helpful? Give feedback.
All reactions