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


  1. i'm curious if possible pure (vanilla) javascript code, entered browser console, extract links (first) page, emulate click go page, extract links there , go third page. extract links means write them console.

  2. the same question 1 link go page makes ajax call update part of page , not go page.

p.s. links belong 1 domain.

any ideas how can done based on pure javascript?

as example, if go google , enter word ("example"), may open console , 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 array of urls (with text, that's ok).

it possible repeat 3 times page 1 page 3 automatically pure javascript?

p.s. should extract tags in code above, tags named "links". sorry confusion (that doesn't change question).

thank again.

if want write links console, can use more specific command

for googles

// firstly, titles var alltitles = document.getelementbyid("ires").getelementsbytagname("h3"); for(var gettitle of alltitles ) { // each title, link.     console.log(gettitle.getelementsbytagname("a")[0].href)  } 

then, need simulate click on nav.

var navlinks = document.getelementbyid("nav").getelementsbytagname("a"); navlinks [navlinks.length-1].click() // click on "next" button. 

for sites

if want links, same command, grab div id want id want part of page, use getelementsbytagname("a")

you can find out how use xhr or other make raw ajax request

simple example found on google :

// jquery $.get('//example.com', function (data) {   // code })  // vanilla var httprequest = new xmlhttprequest() httprequest.onreadystatechange = function (data) {   // code } httprequest.open('get', url) httprequest.send() 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -