-
download poe.js and package.json
-
install require modules
$ npm install
-
copy examples/ and lib/ at current folder
$ cp node_modules/nightwatch/examples $ cp node_modules/nightwatch/lib
-
create tests/ folder
$ mkdir tests
-
be sure to modify the acc and pwd variable in poe.js
-
run command below
$ nightwatch --test tests/poe.js
Last active
November 2, 2020 13:50
-
-
Save tpai/2356257ce73dce0701f0 to your computer and use it in GitHub Desktop.
A web crawler sample based on nightwatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "nightwatch crawler", | |
| "description": "A web crawler sample based on nightwatch.", | |
| "version": "0.0.1", | |
| "author": { | |
| "name": "tonypai", | |
| "email": "tony77794@gmail.com" | |
| }, | |
| "homepage": "https://github.com/tpai", | |
| "dependencies": { | |
| "nightwatch": ">=0.5.33", | |
| "cheerio": ">=0.18.0" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| tags: ['poe'], | |
| 'Get POE Reward Images' : function (client) { | |
| var cheerio = require("cheerio") | |
| var acc = "<your-account>" | |
| var pwd = "<your-password>" | |
| client | |
| .url('http://web.poe.garena.tw/login') | |
| .waitForElementVisible('body', 1000) | |
| .assert.title('Garena') | |
| .assert.visible('#sso_login_form_account') | |
| .setValue('#sso_login_form_account', acc) | |
| .setValue('#sso_login_form_password', pwd) | |
| .waitForElementVisible('#confirm-btn', 1000) | |
| .click('#confirm-btn') | |
| .pause(2000) | |
| .assert.visible('div.tab-links') | |
| .url("http://web.poe.garena.tw/account/view-profile/"+acc+"/events") | |
| .source(function(result) { | |
| $ = cheerio.load(result.value) | |
| var images = $("div.reward img") | |
| for(var i=0;i<images.length;i++) { | |
| console.log($(images[i]).attr("src")); | |
| } | |
| }) | |
| .end(); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment