jeudi 10 novembre 2016

Pure javascript from console: extract links from page, emulate click to another page and do the same

  1. I'm curious if it is possible with pure (vanilla) javascript code, entered into the browser console, to extract all links this (first) page, then emulate a click to go to another page, extract links there and go to the third page. Extract links means to write them into console.

  2. The same question as 1 but link to go to another page makes just an ajax call to update the part of the page and does NOT actually go to another page.

P.S. All links belong to one domain.

Any ideas how can this be done based on pure javascript?

As example, if you go to Google and enter some word ("example"), you may then open the console and enter

var array = [];
var links = document.getElementsByTagName("cite");
for(var i=0; i<links.length; i++) {
    array.push(links[i].innerHTML);
};
console.log(array);

to display the array of URLs (with some text, but that's OK).

It is possible to repeat it 3 times from page 1 to page 3 automatically with pure javascript?

P.S. I should actually extract tags in the code above, so tags I named "links". Sorry for confusion (that doesn't change the question).

Thank you again.




Aucun commentaire:

Enregistrer un commentaire