Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. /* getranks.js
  2. *
  3. * Copyright (c) 2016 xBlau <daniel@blaudev.es>
  4. * Distributed under the terms of the MIT License.
  5. *
  6. * phantomjs[.exe] getranks.js {link} >> ranks.csv
  7. *
  8. */
  9.  
  10. var system = require( 'system' );
  11. var page = require( 'webpage' ).create();
  12.  
  13. function main() {
  14.  
  15. var RankData = page.evaluate( function() {
  16. var Result = '';
  17.  
  18. var TabRows = document.getElementsByClassName( 'table select' )[0].rows;
  19. var Position, Name, Page, Points;
  20.  
  21. var StartIndex = 1;
  22. if( TabRows[1].className == 'paginate' ) {
  23. StartIndex = 2;
  24. }
  25.  
  26. for( i = StartIndex; i < TabRows.length - 1; i++ ) {
  27. if( i != StartIndex ) { Result += "\n"; }
  28.  
  29. Position = TabRows[i].cells[0].innerText;
  30. Name = TabRows[i].cells[1].innerText;
  31. Page = TabRows[i].cells[1].firstChild.href;
  32. Points = TabRows[i].cells[2].innerText.replace( ' ' , '' );
  33.  
  34. Result += Position + ',' + Name + ',' + Page + ',' + Points;
  35. }
  36.  
  37. return Result;
  38. });
  39.  
  40. console.log( RankData );
  41. phantom.exit();
  42. }
  43.  
  44. page.open( system.args[1], main );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement