metalx1000

PhantomJS get first photo in Google Shared Album

Jun 19th, 2020
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/usr/bin/phantomjs
  2. var page = require('webpage').create(),
  3. system = require('system'),
  4. args = system.args;
  5.  
  6. if(args.length < 2){
  7. console.log("Usage: " + args[0] + " '<url>'");
  8. phantom.exit(1);
  9. }
  10.  
  11. page.open(args[1], function(status) {
  12. if (status !== 'success') {
  13. console.log('Unable to load the url!');
  14. phantom.exit();
  15. } else {
  16. window.setTimeout(function () {
  17. var elements = page.content.split("<");
  18. for(e of elements){
  19. if( e.includes("RY3") ){
  20. if( e.includes("lh3") ){
  21. var e = e.split('data-latest-bg="')[1];
  22. e = e.split('"')[0];
  23. console.log(e);
  24. break;
  25. }
  26. }
  27. }
  28. phantom.exit();
  29. }, 2000);
  30. }
  31. });
Add Comment
Please, Sign In to add comment