|
|
|
@ -2,7 +2,6 @@ const ALL_CONTRACTS = require('./contracts');
|
|
|
|
|
|
|
|
|
|
const { Alchemy, Network } = require("alchemy-sdk");
|
|
|
|
|
const { Database } = require('sqlite3');
|
|
|
|
|
const { ethers } = require("ethers");
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -50,11 +49,7 @@ class Scrape {
|
|
|
|
|
console.log('no page key')
|
|
|
|
|
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}`)
|
|
|
|
|
const response = await alchemy.nft.getNftSales({
|
|
|
|
|
fromBlock: this.startBlock,
|
|
|
|
@ -63,11 +58,8 @@ class Scrape {
|
|
|
|
|
order: 'asc',
|
|
|
|
|
pageKey: pageKey
|
|
|
|
|
});
|
|
|
|
|
console.log
|
|
|
|
|
|
|
|
|
|
if (response.pageKey) {
|
|
|
|
|
fs.writeFileSync(this.lastFile, response.pageKey)
|
|
|
|
|
}
|
|
|
|
|
fs.writeFileSync(this.lastFile, response.pageKey || '')
|
|
|
|
|
|
|
|
|
|
response.nftSales.map(async (sale) => {
|
|
|
|
|
const rowExists = await new Promise((resolve) => {
|
|
|
|
@ -104,9 +96,6 @@ class Scrape {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await sleep(1);
|
|
|
|
|
|
|
|
|
@ -158,7 +147,7 @@ class Scrape {
|
|
|
|
|
} catch(e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
}
|
|
|
|
|
await sleep(3);
|
|
|
|
|
await sleep(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})();
|