From a0d4686c11c803a10678704dd9f5cd2678c7e8b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Sverre=20Lien=20Sell=C3=A6g?= Date: Wed, 6 Jul 2022 21:15:39 +0200 Subject: [PATCH] add update of scraper --- bin/scrape.mjs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/scrape.mjs b/bin/scrape.mjs index a85dfc6..e7f2a88 100644 --- a/bin/scrape.mjs +++ b/bin/scrape.mjs @@ -86,7 +86,6 @@ const updated = (oldEvent, scrapedEvent) => { ticket_url: event.event_buy_ticket_url ?? '' }); } - if (payloads.length < 2) { console.log(123, JSON.stringify(payloads)); } @@ -95,9 +94,7 @@ const updated = (oldEvent, scrapedEvent) => { `${api}/search/events/?facebook_id=${payload.facebook_id}&token=${token}` ); if (!search.ok) { - console.log('hææææ'); - console.log(await search.text()); - await sleep(200); + console.log(500, await search.text()); continue; } search = await search.json(); @@ -136,5 +133,13 @@ const updated = (oldEvent, scrapedEvent) => { console.log(201, 'Skip', place.name, payload.name); } } + let res = await fetch(`${api}/places/${place.id}/?token=${token}`, { + method: 'PATCH', + body: JSON.stringify({ + last_scraped: unix(new Date()) + }), + headers + }); + console.log(res.status, 'Updated last scraped'); } })();