Last active
November 2, 2020 13:50
-
-
Save tpai/2356257ce73dce0701f0 to your computer and use it in GitHub Desktop.
Revisions
-
tpai revised this gist
Nov 12, 2014 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ Instruction --- 1) download poe.js, package.json and latest version of [selenium server](http://selenium-release.storage.googleapis.com/index.html) into the same folder 2) install require modules @@ -19,11 +19,17 @@ Instruction $ mkdir tests 5) modify the acc and pwd variable in poe.js, and move it to tests/ folder. $ mv poe.js tests/ 6) launch selenium server (must install firefox) $ java -jar selenium-server-standalone-{VERSION}.jar 7) run command below $ nightwatch --test tests/poe -
tpai revised this gist
Nov 12, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ Instruction --- 1) download poe.js, package.json and latest version of [selenium server](http://selenium-release.storage.googleapis.com/index.html) 2) install require modules @@ -26,4 +26,4 @@ Instruction $ nightwatch --test tests/poe.js **P.S. Be sure to install firefox and launch selenium server.** -
tpai revised this gist
Nov 11, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Instruction $ mkdir tests 5) be sure to modify the acc and pwd variable in poe.js, and move it to tests/ folder. 6) run command below -
tpai revised this gist
Nov 11, 2014 . 2 changed files with 6 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ { "name": "nightwatch_webcrawler", "description": "A web crawler sample based on nightwatch.", "version": "0.0.1", "author": { 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 charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,8 @@ Instruction 3) copy examples/ and lib/ at current folder $ cp node_modules/nightwatch/examples . $ cp node_modules/nightwatch/lib . 4) create tests/ folder @@ -24,4 +24,6 @@ Instruction 6) run command below $ nightwatch --test tests/poe.js **P.S. Be sure to install firefox.** -
tpai renamed this gist
Nov 10, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tpai revised this gist
Nov 10, 2014 . 1 changed file with 21 additions and 22 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,30 @@ module.exports = { tags: ['poe'], 'Get POE Reward Images' : function (client) { var cheerio = require("cheerio") // easy to parse HTML 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) { // .source() will dump the target page into text format $ = cheerio.load(result.value) // so it needs to be parse var images = $("div.reward img") for(var i=0;i<images.length;i++) { console.log($(images[i]).attr("src")); } }) .end(); } }; -
tpai revised this gist
Nov 10, 2014 . 2 changed files with 11 additions and 34 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +0,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 charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,27 @@ Instruction --- 1) download poe.js and package.json 2) install require modules $ npm install 3) copy examples/ and lib/ at current folder $ cp node_modules/nightwatch/examples $ cp node_modules/nightwatch/lib 4) create tests/ folder $ mkdir tests 5) be sure to modify the acc and pwd variable in poe.js 6) run command below $ nightwatch --test tests/poe.js -
tpai revised this gist
Nov 10, 2014 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,27 @@ Instruction --- 1) download poe.js and package.json 2) install require modules $ npm install 3) copy examples/ and lib/ at current folder $ cp node_modules/nightwatch/examples $ cp node_modules/nightwatch/lib 4) create tests/ folder $ mkdir tests 5) be sure to modify the acc and pwd variable in poe.js 6) run command below $ nightwatch --test tests/poe.js -
tpai revised this gist
Nov 10, 2014 . 1 changed file with 27 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ Instruction --- 1. download poe.js and package.json 2. install require modules $ npm install 3. copy examples/ and lib/ at current folder $ cp node_modules/nightwatch/examples $ cp node_modules/nightwatch/lib 4. create tests/ folder $ mkdir tests 5. be sure to modify the acc and pwd variable in poe.js 6. run command below $ nightwatch --test tests/poe.js -
tpai renamed this gist
Nov 10, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tpai revised this gist
Nov 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,4 @@ Instruction 6. run command below $ nightwatch --test tests/poe -
tpai created this gist
Nov 10, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ Instruction --- 1. download poe.js and package.json 2. install require modules $ npm install 3. copy examples/ and lib/ at current folder $ cp node_modules/nightwatch/examples $ cp node_modules/nightwatch/lib 4. create tests/ folder $ mkdir tests 5. be sure to modify the acc and pwd variable in poe.js 6. run command below $ nightwatch --test tests/poe.js 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ { "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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ 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(); } };