Last active
June 30, 2017 21:15
-
-
Save osya/d71c41a0836aa380f8c85425d8a47e1c to your computer and use it in GitHub Desktop.
JavaScript script for some PhantomJS automation #JavaScript
This file contains 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
/** | |
* Created by info_000 on 30-Jun-17. | |
*/ | |
"use strict"; | |
var page = require('webpage').create(), | |
fs = require('fs'); | |
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'; | |
page.onError = function (msg, trace) { | |
console.log(msg); | |
trace.forEach(function(item) { | |
console.log(' ', item.file, ':', item.line); | |
}); | |
}; | |
page.onConsoleMessage = function(msg, lineNum, sourceId) { | |
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")'); | |
}; | |
page.open('http://www.portalinmobiliario.com/propiedades/mapa', function(status) { | |
if (status === "success") { | |
page.includeJs("https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js", function() { | |
page.evaluate(function() { | |
$("#show-login-prompt").click(); | |
}); | |
window.setTimeout(function () { | |
page.evaluate(function() { | |
$('#txtEmail').val('[email protected]'); | |
$('#txtPassword').val('andeschile'); | |
$("#linkIngresar").click() | |
}); | |
window.setTimeout(function() { | |
page.render('output.png'); | |
fs.write('output.html', page.content, 'w'); | |
debugger; | |
phantom.exit(0); | |
}, 5000); | |
}, 2000); | |
}); | |
} else { | |
console.log('Unable to access network'); | |
phantom.exit(1); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment