Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var page = require('webpage').create();
- page.open("http://www.neakaisa.ro", function(status){
- console.log('status '+status)
- if(status=='success'){
- console.log('inside status if ');
- // page.includeJs("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js", function() {
- // console.log('after include js ')
- /*var links = page.evaluate(function () {
- return [].map.call(document.querySelectorAll('a'), function(link) {
- var x = link.getAttribute('href');
- return x;
- });
- });
- links.split(",");
- console.log(links);*/
- //console.log(links.join('\n'));
- var links = page.evaluate(function() {
- var arr = [], l = document.links;
- var linkToFind = [ "http://www.anpc.gov.ro",
- "https://www.anpc.gov.ro",
- "http://anpc.gov.ro",
- "https://anpc.gov.ro",
- "www.anpc.gov.ro",
- "anpc.gov.ro"
- ];
- var newArr = [];
- for(var i=0;i<l.length;i++) {
- arr.push(l[i].href);
- }
- arr.forEach
- (
- (e1)=>linkToFind.forEach
- (
- (e2)=>
- {
- if(e1 === e2)
- {
- newArr.push(e1);
- }
- }
- )
- );
- return newArr;
- });
- /*var arr = [], l = document.links;
- for(var i=0; i<l.length; i++) {
- arr.push(l[i].href);
- }
- for(var i=0;i<l.length;i++) {
- if(l[i].includes("anpc.gov.ro")) {
- console.log("exists");
- }
- else {
- console.log("not exists");
- }
- }*/
- console.log(links.join("\n"));
- phantom.exit()
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement