Click here to Skip to main content
15,885,074 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi.I want to extract the addresses of the links of PDFs which are available at multiple webpages or all the open tabs,from the same web site(i DON'T mean the addresses of the webpages or the tabs themselves).Please let me know how to do it in an as easy as possible way,i don't have any code writing experience.

What I have tried:

I've googled it,but wasn't helpful.
Posted
Updated 6-Aug-18 2:52am

1 solution

Not entirely sure what you're looking for, but you could use jQuery.

JavaScript
var links = [];
$('a').each(function() {
   links.push( this.href ); 
   // output of links: ['http://www.google.com', 'http://www.dictionay.com']
   // According to comment
   // if you need each link separately then
   // may try like

   var href = this.href;
   console.log(href);
});


That script will print every link that is found on the page out to the browser's console.log.

I got the basic script at javascript - get all the links in a page using jquery - Stack Overflow[^] and then slightly altered it.

If you press F12 in your browser right now it'll open Dev Tools (Chrome, Edge). You can then copy the code and paste it into the Console and run it right here on this page.

You can see a snapshot of where I ran it on this page at : https://i.stack.imgur.com/V7Zvr.png

I know you only want the PDFs, but you can alter the script from here.
 
Share this answer
 
Comments
Member 13939421 6-Aug-18 11:03am    
Thanks.You know,i don't have any good code writing experience.So,the java code
you mentioned makes almost no sense to me.
I got many tabs open in my browser,and i want to make a list of the links of the PDF files available at each tab,at once,not tab by tab.And all the tabs
are webpages of a same website.Please,tell me what to do.
I can make a list of the urls of all the tabs.I've just thought,By that you may be able to give me some method.
MadMyche 6-Aug-18 11:51am    
Tabs are isolated within the browser process for your safety. Scripts in one tab cannot access the contents of another tab

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900