Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. var page = require('webpage').create();
  2. page.open("http://www.neakaisa.ro", function(status){
  3. console.log('status '+status)
  4. if(status=='success'){
  5. console.log('inside status if ');
  6. // page.includeJs("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js", function() {
  7. // console.log('after include js ')
  8.  
  9. /*var links = page.evaluate(function () {
  10. return [].map.call(document.querySelectorAll('a'), function(link) {
  11. var x = link.getAttribute('href');
  12.  
  13. return x;
  14.  
  15. });
  16. });
  17. links.split(",");
  18. console.log(links);*/
  19. //console.log(links.join('\n'));
  20. var links = page.evaluate(function() {
  21. var arr = [], l = document.links;
  22. var linkToFind = [ "http://www.anpc.gov.ro",
  23. "https://www.anpc.gov.ro",
  24. "http://anpc.gov.ro",
  25. "https://anpc.gov.ro",
  26. "www.anpc.gov.ro",
  27. "anpc.gov.ro"
  28. ];
  29. var newArr = [];
  30. for(var i=0;i<l.length;i++) {
  31. arr.push(l[i].href);
  32. }
  33. arr.forEach
  34. (
  35. (e1)=>linkToFind.forEach
  36. (
  37. (e2)=>
  38. {
  39. if(e1 === e2)
  40. {
  41. newArr.push(e1);
  42. }
  43. }
  44. )
  45. );
  46. return newArr;
  47. });
  48.  
  49. /*var arr = [], l = document.links;
  50. for(var i=0; i<l.length; i++) {
  51. arr.push(l[i].href);
  52. }
  53. for(var i=0;i<l.length;i++) {
  54. if(l[i].includes("anpc.gov.ro")) {
  55. console.log("exists");
  56. }
  57. else {
  58. console.log("not exists");
  59. }
  60. }*/
  61. console.log(links.join("\n"));
  62.  
  63.  
  64. phantom.exit()
  65.  
  66. }
  67. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement