close
還是在 c9.io 測試 , 先裝到 node js v8 版本
testuser:~/workspace $ node -v v6.11.2 testuser:~/workspace $ nvm install 8 Downloading https://nodejs.org/dist/v8.9.1/node-v8.9.1-linux-x64.tar.xz... ######################################################################## 100.0% Now using node v8.9.1 (npm v5.5.1) testuser:~/workspace $ node -v v8.9.1 testuser:~/workspace $ npm install puppeteer > puppeteer@0.13.0 install /home/ubuntu/workspace/node_modules/puppeteer > node install.js Downloading Chromium r515411 - 95.4 Mb [====================] 100% 0.0s Chromium downloaded to /home/ubuntu/workspace/node_modules/puppeteer/.local-chromium/linux-515411 npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN chat-example@0.0.0 No repository field. npm WARN chat-example@0.0.0 No license field. + puppeteer@0.13.0 added 41 packages in 11.932s testuser:~/workspace $ npm install sleep > sleep@5.1.1 install /home/ubuntu/workspace/node_modules/sleep > node-gyp rebuild gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR make: Entering directory `/home/ubuntu/workspace/node_modules/sleep/build' CXX(target) Release/obj.target/node_sleep/sleep.o SOLINK_MODULE(target) Release/obj.target/node_sleep.node COPY Release/node_sleep.node make: Leaving directory `/home/ubuntu/workspace/node_modules/sleep/build' npm WARN chat-example@0.0.0 No repository field. npm WARN chat-example@0.0.0 No license field. + sleep@5.1.1 added 2 packages in 3.023s
run.js 內容: (wget https://echochio-tw.github.io/run.js 抓 .....XD)
const puppeteer = require('puppeteer'); var sleep = require('sleep'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://echochio-tw.github.io/chrome-test.html'); await page.waitFor(1000); while (true) { sleep.sleep(5); html = await page.content(); console.log(html.substring(html.indexOf("<a",1),html.indexOf("<br>",1))); } })();
執行 run.js 結果
testuser:~/workspace $ node run.js <a id="hps">hashes per second: 0</a> <a id="ths">Total Hashes: 0</a> <a id="tcount">Threads: 8</a> <a id="tah">Accepted Hashes: 305</a> <a id="hps">hashes per second: 4.48</a> <a id="ths">Total Hashes: 22</a> <a id="tcount">Threads: 8</a> <a id="tah">Accepted Hashes: 305</a> <a id="hps">hashes per second: 5.68</a> <a id="ths">Total Hashes: 45</a> <a id="tcount">Threads: 8</a> <a id="tah">Accepted Hashes: 306</a> <a id="hps">hashes per second: 4.57</a> <a id="ths">Total Hashes: 75</a> <a id="tcount">Threads: 8</a> <a id="tah">Accepted Hashes: 307</a>
全站熱搜