Advertisement
Guest User

Untitled

a guest
Feb 1st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. var username = "my_username", password = "my_password";
  2. var address = "http://my_url_address.com", sources = [];
  3.  
  4. var casper = require('casper').create({
  5. waitTimeout: 30000,
  6. viewportSize: {
  7. width: 1024,
  8. height: 768
  9. },
  10. clientScripts: [
  11. 'jquery.min.js',
  12. 'jquery.cookie.js'
  13. ],
  14. pageSettings: {
  15. loadImages: false,
  16. verbose: true,
  17. logLevel: 'debug'
  18. }
  19. });
  20.  
  21. casper.on("resource.received", function(resource) {
  22. console.log(resource.contentType);
  23. if (resource.contentType == 'my_content_type') {
  24. sources.push(resource.url);
  25. }
  26. });
  27.  
  28. casper.start(address, function() {
  29. this.waitForSelector('#login', function() {
  30. this.click('#login');
  31. });
  32. });
  33.  
  34. casper.then(function() {
  35. this.evaluate(function(username, password) {
  36. document.querySelector('#username').value = username;
  37. document.querySelector('#password').value = password;
  38. document.querySelector('#loginSend').click();
  39. }, username, password);
  40.  
  41. this.wait(4000, function() {
  42. this.open(address + "/resource_path_of_the_video");
  43. });
  44. });
  45.  
  46. casper.then(function() {
  47. this.wait(30000, function() {
  48. });
  49.  
  50. casper.run(function() {
  51. this.echo("finish");
  52. this.exit();
  53. });
  54.  
  55. this.wait(4000, function() {
  56. this.open(address + "/resource_path_of_the_video");
  57. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement