master
lza_menace 4 weeks ago
parent 6084590d50
commit c62281b2f6

@ -2,7 +2,6 @@ const ALL_CONTRACTS = require('./contracts');
const { Alchemy, Network } = require("alchemy-sdk"); const { Alchemy, Network } = require("alchemy-sdk");
const { Database } = require('sqlite3'); const { Database } = require('sqlite3');
const { ethers } = require("ethers");
const fs = require('fs'); const fs = require('fs');
@ -50,11 +49,7 @@ class Scrape {
console.log('no page key') console.log('no page key')
return return
} }
db.get('SELECT * FROM events WHERE contract = ? COLLATE NOCASE AND page_key = ? COLLATE NOCASE LIMIT 1', [this.contractAddress, pageKey], async (err, row) => {
if (row) {
console.log('page key exists, skipping');
return
} else {
console.log(`[+] Scraping ${this.contractName} with pageKey ${pageKey}`) console.log(`[+] Scraping ${this.contractName} with pageKey ${pageKey}`)
const response = await alchemy.nft.getNftSales({ const response = await alchemy.nft.getNftSales({
fromBlock: this.startBlock, fromBlock: this.startBlock,
@ -63,11 +58,8 @@ class Scrape {
order: 'asc', order: 'asc',
pageKey: pageKey pageKey: pageKey
}); });
console.log
if (response.pageKey) { fs.writeFileSync(this.lastFile, response.pageKey || '')
fs.writeFileSync(this.lastFile, response.pageKey)
}
response.nftSales.map(async (sale) => { response.nftSales.map(async (sale) => {
const rowExists = await new Promise((resolve) => { const rowExists = await new Promise((resolve) => {
@ -104,9 +96,6 @@ class Scrape {
} }
} }
}); });
}
});
await sleep(1); await sleep(1);
@ -158,7 +147,7 @@ class Scrape {
} catch(e) { } catch(e) {
console.log(e); console.log(e);
} }
await sleep(3); await sleep(1);
} }
} }
})(); })();
Loading…
Cancel
Save