-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.js
30 lines (28 loc) · 1 KB
/
fetch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs');
const fyers = require('extra-fyers');
const {sleep} = require('extra-sleep');
const download = require('download');
async function logos() {
var nsecm = await fyers.loadSymbolMaster(null, 'NSE', 'CM');
var bsecm = await fyers.loadSymbolMaster(null, 'BSE', 'CM');
var isins = new Map();
for (var x of nsecm)
isins.set(x.isin, x);
for (var x of bsecm)
isins.set(x.isin, x);
for (var [isin, x] of isins) {
if (fs.existsSync(`data/${isin}.log`)) continue;
if (fs.existsSync(`data/${isin}.png`)) continue;
console.log(`Fetching ${isin} (${x.symbol}; ${x.description}) ...`);
try {
await download(`https://assets-netstorage.groww.in/stock-assets/logos/${isin}.png`, 'data');
console.log(`Fetched ${isin}. Waiting 10s ...`);
}
catch (e) {
fs.writeFileSync(`data/${isin}.log`, `${e.message}\n${x.symbol}; ${x.description}\n`);
console.log(`Fetch ${isin} failed! Waiting 10s ...`);
}
await sleep(10000);
}
}
logos();