Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = require('./config.json');
- var login = require('./functions/login.js');
- var data = require('./functions/data.js');
- var vo = require('vo');
- var Nightmare = require('nightmare'),
- nightmare = new Nightmare({
- show: config.nightmare.show,
- typeInterval: config.nightmare.typeInterval,
- webPreferences: {
- images: config.nightmare.images,
- }
- });
- vo(login.login)(nightmare, function (err, result) {
- if (!result) return;
- console.log('Logged in as ' + config.user.username)
- vo(data.getData)(nightmare, function (err, result) {
- console.log(result);
- })
- })
- var config = require('../config.json');
- var Nightmare = require('nightmare')
- function* login(nightmare) {
- return yield nightmare
- .goto('http://example.com/')
- .click('.gogo').wait(2500)
- .insert('.whsOnd', config.user.username)
- .click('.RveJvd').wait(2500)
- .insert('.whsOnd', config.user.password)
- .click('.RveJvd').wait(4000)
- .then(() => {
- return true;
- })
- }
- //login works
- module.exports = {
- login: login
- }
- var config = require('../config.json');
- var Nightmare = require('nightmare')
- function* getData(nightmare) {
- console.log('Getting data ...' + nightmare)
- return yield nightmare
- .click('.index_menu').wait(1000)
- .evaluate(()=>{
- // do stuff
- })
- .then((result) => {
- return result;
- })
- .catch((error) => {
- console.log('Failure: ' + error)
- })
- }
- module.exports = {
- getData: getData
- }
Add Comment
Please, Sign In to add comment