Guest User

Untitled

a guest
Oct 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. var config = require('./config.json');
  2. var login = require('./functions/login.js');
  3. var data = require('./functions/data.js');
  4. var vo = require('vo');
  5.  
  6. var Nightmare = require('nightmare'),
  7. nightmare = new Nightmare({
  8. show: config.nightmare.show,
  9. typeInterval: config.nightmare.typeInterval,
  10. webPreferences: {
  11. images: config.nightmare.images,
  12. }
  13. });
  14.  
  15. vo(login.login)(nightmare, function (err, result) {
  16. if (!result) return;
  17. console.log('Logged in as ' + config.user.username)
  18. vo(data.getData)(nightmare, function (err, result) {
  19. console.log(result);
  20. })
  21. })
  22.  
  23. var config = require('../config.json');
  24. var Nightmare = require('nightmare')
  25.  
  26. function* login(nightmare) {
  27. return yield nightmare
  28. .goto('http://example.com/')
  29. .click('.gogo').wait(2500)
  30. .insert('.whsOnd', config.user.username)
  31. .click('.RveJvd').wait(2500)
  32. .insert('.whsOnd', config.user.password)
  33. .click('.RveJvd').wait(4000)
  34. .then(() => {
  35. return true;
  36. })
  37. }
  38. //login works
  39.  
  40. module.exports = {
  41. login: login
  42. }
  43.  
  44. var config = require('../config.json');
  45. var Nightmare = require('nightmare')
  46.  
  47. function* getData(nightmare) {
  48. console.log('Getting data ...' + nightmare)
  49. return yield nightmare
  50. .click('.index_menu').wait(1000)
  51. .evaluate(()=>{
  52. // do stuff
  53. })
  54. .then((result) => {
  55. return result;
  56. })
  57. .catch((error) => {
  58. console.log('Failure: ' + error)
  59. })
  60. }
  61.  
  62. module.exports = {
  63. getData: getData
  64. }
Add Comment
Please, Sign In to add comment