Last Updated: February 25, 2016
·
837
· younes

How to post tweet on Twitter using NightmareJS

NightmareJS is nice replacement of CasperJS and PhantomeJS, it comes with simple API.

Here is a example of how to post a tweet on Twitter

var Nightmare = require('nightmare');
var vo = require('vo');

vo(function* () {
 var nightmare = Nightmare({ show: true });
 var link = yield nightmare
 .goto('http://twitter.com/intent/tweet')
 .type('#status', "Insert tweet here")
 .type('#username_or_email', "Insert email here")
 .type('#password', "Insert password here")
 .click('.button')
 yield nightmare.end();
})(function (err, result) {
 if (err) return console.log(err);
});

If you want to hide the chromium window just change to show property to false.