Crafty
09/04/2024, 1:17 PMserve-file
and file
changes regularly.
My strategy to deal with this is to calculate the unique key based on the 'stable' parts of the url. Then when i detect the url has changed, I can remove any queued requests with the unique key and replace them with the new url
My question is, if a request has hit its retry limit and has been 'blacklisted' from the request queue, how can i remove it so the new url can be processed?
Thanks!Hall
09/04/2024, 1:17 PMPepa J
09/05/2024, 8:41 AMid
through the API.
If you know only uniqueKey
, then I suggest you to add new Request
to the RequestQueue
with the same uniqueKey
-> It will end with response aving attribute wasAlreadyPresent
set to true , but you should also obtain the stored Request data (with id
).
When you have the Request id
, you may do DELETE Http Request see https://docs.apify.com/api/v2#tag/Request-queuesQueue/operation/requestQueue_request_delete to delete it.Crafty
09/05/2024, 11:24 AMtypescript
const requestQueue = await crawler.getRequestQueue();
const result = await requestQueue.addRequest({url: 'https://google.com', uniqueKey: 'aaa', label: 'secondary'})
log.info('result', result)
if (result.wasAlreadyPresent) {
log.info('already present')
const request = await requestQueue.getRequest(result.requestId);
log.info('request', request)
}
Pepa J
09/05/2024, 11:43 AMuniqueKey->requestId
relation as a key pair value there. 🤔Crafty
09/05/2024, 11:45 AMaddRequest
must be doing it under the hood.