TEst16
TEst16

Reputation: 407

How to extract a list of links from a page in Javascript

I want to get a list of all videos a Youtube user has uploaded. Say I go to http://www.youtube.com/user/bertrandleroy/videos and click "Load more" until all are loaded. There is a div with id 'video-page-content' that contains links to all the videos. How can I produce a list of links. I'd prefer to just use the dev tools in Chrome or Firebug, if possible.

Upvotes: 0

Views: 233

Answers (1)

flero
flero

Reputation: 70

Using chrome you could use something like:

var list=document.getElementsByClassName('yt-uix-contextlink');
for (i=0;i<list.length;i++)
{
console.log(list[i].getAttribute("href"));
}

Paste it in the console tab.

This will actually produce 2 links (/watch...) for each video.

Upvotes: 2

Related Questions