mirror of
https://github.com/oceanprotocol/community-numbers.git
synced 2024-12-22 17:23:31 +01:00
use chrome-aws-lambda
This commit is contained in:
parent
bf53963fe0
commit
45a0e6ade2
@ -1,11 +1,16 @@
|
|||||||
import puppeteer from 'puppeteer'
|
import chrome from 'chrome-aws-lambda'
|
||||||
|
import puppeteer from 'puppeteer-core'
|
||||||
import { log } from '../utils'
|
import { log } from '../utils'
|
||||||
|
|
||||||
export default async function fetchDiscord() {
|
export default async function fetchDiscord() {
|
||||||
const url = 'https://discord.com/invite/TnXjkR5'
|
const url = 'https://discord.com/invite/TnXjkR5'
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
|
|
||||||
const browser = await puppeteer.launch({ headless: true })
|
const browser = await puppeteer.launch({
|
||||||
|
args: chrome.args,
|
||||||
|
executablePath: await chrome.executablePath,
|
||||||
|
headless: chrome.headless
|
||||||
|
})
|
||||||
const page = await browser.newPage()
|
const page = await browser.newPage()
|
||||||
await page.goto(url)
|
await page.goto(url)
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ export default async function fetchTelegram() {
|
|||||||
.replace(' members', '')
|
.replace(' members', '')
|
||||||
.replace(' ', '')
|
.replace(' ', '')
|
||||||
.replace(' ', '')
|
.replace(' ', '')
|
||||||
const membersCommunity = parseInt(infoCommunity)
|
const community = parseInt(infoCommunity)
|
||||||
|
|
||||||
log(
|
log(
|
||||||
'Re-fetched Telegram. ' +
|
'Re-fetched Telegram. ' +
|
||||||
`Total: ${membersCommunity} oceanprotocol_community members. ` +
|
`Total: ${community} oceanprotocol_community members. ` +
|
||||||
`Elapsed: ${new Date() - start}ms`
|
`Elapsed: ${new Date() - start}ms`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ export default async function fetchTelegram() {
|
|||||||
|
|
||||||
let infoNews = dataNews('.tgme_page_extra').text()
|
let infoNews = dataNews('.tgme_page_extra').text()
|
||||||
infoNews = infoNews.replace(' members', '').replace(' ', '').replace(' ', '')
|
infoNews = infoNews.replace(' members', '').replace(' ', '').replace(' ', '')
|
||||||
const membersNews = parseInt(infoNews)
|
const news = parseInt(infoNews)
|
||||||
|
|
||||||
log(
|
log(
|
||||||
'Re-fetched Telegram. ' +
|
'Re-fetched Telegram. ' +
|
||||||
`Total: ${membersCommunity} oceanprotocol members. ` +
|
`Total: ${news} oceanprotocol members. ` +
|
||||||
`Elapsed: ${new Date() - start}ms`
|
`Elapsed: ${new Date() - start}ms`
|
||||||
)
|
)
|
||||||
|
|
||||||
return { community: membersCommunity, news: membersNews }
|
return { community, news }
|
||||||
}
|
}
|
||||||
|
147
package-lock.json
generated
147
package-lock.json
generated
@ -274,6 +274,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
|
||||||
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="
|
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="
|
||||||
},
|
},
|
||||||
|
"chrome-aws-lambda": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/chrome-aws-lambda/-/chrome-aws-lambda-3.1.1.tgz",
|
||||||
|
"integrity": "sha512-ikOcpFgobiiUvDXtBft+jxVz2CsauRV58owDtVyF1ocl/YN+/eqdIrrmbItm3yeJGnb9RtKxzFAqGcpBTQbTCA==",
|
||||||
|
"requires": {
|
||||||
|
"lambdafs": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cli-cursor": {
|
"cli-cursor": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
|
||||||
@ -1509,6 +1517,117 @@
|
|||||||
"object.assign": "^4.1.0"
|
"object.assign": "^4.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"lambdafs": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lambdafs/-/lambdafs-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-HqRPmEgtkTW4sCYDUjTEuTGkjCHuLvtZU8iM8GkhD7SpjW4AJJbBk86YU4K43sWGuW5Vmzp1lVCx4ab/kJsuBw==",
|
||||||
|
"requires": {
|
||||||
|
"tar-fs": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bl": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"readable-stream": "^3.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"chownr": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"end-of-stream": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"once": "^1.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fs-constants": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"inherits": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"minimist": {
|
||||||
|
"version": "0.0.8",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"mkdirp": {
|
||||||
|
"version": "0.5.1",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"minimist": "0.0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"once": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"wrappy": "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pump": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"end-of-stream": "^1.1.0",
|
||||||
|
"once": "^1.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"readable-stream": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"inherits": "^2.0.3",
|
||||||
|
"string_decoder": "^1.1.1",
|
||||||
|
"util-deprecate": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"safe-buffer": {
|
||||||
|
"version": "5.2.0",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "~5.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tar-fs": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"chownr": "^1.1.1",
|
||||||
|
"mkdirp": "^0.5.1",
|
||||||
|
"pump": "^3.0.0",
|
||||||
|
"tar-stream": "^2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tar-stream": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"bundled": true,
|
||||||
|
"requires": {
|
||||||
|
"bl": "^3.0.0",
|
||||||
|
"end-of-stream": "^1.4.1",
|
||||||
|
"fs-constants": "^1.0.0",
|
||||||
|
"inherits": "^2.0.3",
|
||||||
|
"readable-stream": "^3.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"util-deprecate": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"bundled": true
|
||||||
|
},
|
||||||
|
"wrappy": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"bundled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"levn": {
|
"levn": {
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
||||||
@ -1924,6 +2043,34 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"puppeteer-core": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-Tb5FVp9h9wkd2gXpc/qfBFFI7zjLxxe3pw34U5ntpSnIoUV2m9IKIjAf7ou+5N3fU9VPV3MNJ3HQiDVasN/MPQ==",
|
||||||
|
"requires": {
|
||||||
|
"debug": "^4.1.0",
|
||||||
|
"extract-zip": "^2.0.0",
|
||||||
|
"https-proxy-agent": "^4.0.0",
|
||||||
|
"mime": "^2.0.3",
|
||||||
|
"mitt": "^2.0.1",
|
||||||
|
"progress": "^2.0.1",
|
||||||
|
"proxy-from-env": "^1.0.0",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"tar-fs": "^2.0.0",
|
||||||
|
"unbzip2-stream": "^1.3.3",
|
||||||
|
"ws": "^7.2.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"react-is": {
|
"react-is": {
|
||||||
"version": "16.9.0",
|
"version": "16.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
|
||||||
|
@ -9,8 +9,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"cheerio": "^1.0.0-rc.3",
|
"cheerio": "^1.0.0-rc.3",
|
||||||
|
"chrome-aws-lambda": "^3.1.1",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"puppeteer": "^4.0.0"
|
"puppeteer": "^4.0.0",
|
||||||
|
"puppeteer-core": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^7.2.0",
|
"eslint": "^7.2.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user