Last active
August 6, 2023 12:03
-
-
Save observerss/3798922 to your computer and use it in GitHub Desktop.
Revisions
-
observerss revised this gist
Oct 21, 2013 . 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 @@ -1,6 +1,6 @@ // EDIT: 2013/10/20 // google has updated its kwt UI, this script doesn't work any more! // may be I will update this script when I have time to investigate their new Interface. // requires -
observerss revised this gist
Oct 21, 2013 . 1 changed file with 3 additions and 3 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,6 +1,6 @@ // EDIT: 2013/10/20 // google has updated its kwt UI, this script doesn't work any more! // may be I will update this script if when I have time to investigate their new Interface. // requires -
observerss revised this gist
Oct 21, 2013 . 1 changed file with 5 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 @@ -1,3 +1,8 @@ # EDIT: 2013/10/20 # google has updated its kwt UI, this script doesn't work any more! # may be I will update this script if when I have time to investigate their new Interface. // requires var utils = require('utils'); var casper = require('casper').create() -
observerss revised this gist
Oct 18, 2012 . 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 @@ -48,7 +48,7 @@ function start(kwurl) { function query(kws){ this.thenEvaluate(function(kws){ document.querySelector('.sEAB').value = kws.join('\n'); document.querySelector('button.gwt-Button').click(); }, {kws:kws}); } -
observerss revised this gist
Sep 28, 2012 . No changes.There are no files selected for viewing
-
observerss created this gist
Sep 28, 2012 .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,93 @@ // requires var utils = require('utils'); var casper = require('casper').create() var casper = require('casper').create({ verbose: true, logLevel: "debug" }); // setup globals var email = casper.cli.options['email'] || 'REPLACE THIS EMAIL'; var passwd = casper.cli.options['passwd'] || 'REPLACE THIS PASSWORD'; var keywords = casper.cli.options['keywords'] || 'iphone,cars,kindle'; keywords = keywords.split(','); var kwurl = '' var result = {} var kws_list = []; for (var j=0; j<((keywords.length-1)/50+1); j++) { kws_list.push( keywords.slice(j*50, j*50+50) ); } // login & save url casper.start('http://adwords.google.com'); casper.thenEvaluate(function login(email, passwd) { document.querySelector('#Email').setAttribute('value', email); document.querySelector('#Passwd').setAttribute('value', passwd); document.querySelector('form').submit(); }, {email:email, passwd:passwd}); casper.waitForSelector(".aw-cues-item", function() { kwurl = this.evaluate(function(){ var search = document.location.search; return 'https://adwords.google.com/o/Targeting/Explorer'+search+'&__o=cues&ideaRequestType=KEYWORD_IDEAS'; }) //this.open(kwurl); }); // control flows function start(kwurl) { this.start(kwurl); // we should start a new page, // don't worry, we are still logged in // ``this.open`` won't work here this.waitForSelector("button.gwt-Button", function(){}); } function query(kws){ this.thenEvaluate(function(kws){ document.querySelector('.sEAB').textContent = kws.join('\n'); document.querySelector('button.gwt-Button').click(); }, {kws:kws}); } function parseresults(){ this.waitForSelector('#gwt-debug-column-GLOBAL_MONTHLY_SEARCHES-row-0-3', function() { var o = this.evaluate(function(){ var o = {}; var els = document.querySelectorAll('a.sCM'); for (var i=0; i<els.length; i++){ var el = els[i]; pel = el.parentElement.parentElement.parentElement.parentElement.parentElement; o[el.textContent] = [pel.nextSibling.nextSibling.textContent, pel.nextSibling.nextSibling.nextSibling.textContent]; }; return o }); for (var k in o){ result[k] = o[k]; } }); } // recusively call so that it runs sequentially var current_kws = 0; function check_kws(){ if (kws_list[current_kws] && kws_list[current_kws].length>0){ var kws = kws_list[current_kws]; start.call(this, kwurl); query.call(this, kws); parseresults.call(this); current_kws++; this.run( check_kws ); }else{ this.echo("All done"); utils.dump(result); this.exit() } }; casper.run(check_kws)