如何从多个网页中提取链接或从同一网站打开标签? [英] How to extract links which are available at multiple web pages or open tabs from the same websites?

查看:132
本文介绍了如何从多个网页中提取链接或从同一网站打开标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。我想从同一个网站(我不是指网页的地址或标签本身)提取多个网页或所有打开的标签页面上提供的PDF链接的地址。请尽可能简单地告诉我如何操作,我没有任何代码编写经验。



我尝试过:



我用谷歌搜索了它,但没有帮助。

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.

推荐答案

Not完全确定你在寻找什么,但你可以使用jQuery。



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

var links = [];


' a')。each( function (){
links.push( this .href) ;
// 链接输出:['http://www.google.com','http ://www.dic tionay.com']
// 根据评论
// 如果您需要单独链接,那么
// 可能会尝试

var href = < span class =code-keyword> this .href;
console .log(href);
});
('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); });





该脚本将打印页面上找到的每个链接到浏览器的console.log。



我在 javascript - 使用jquery获取页面中的所有链接 - Stack Overflow [ ^ ]然后略微修改它。



如果您现在在浏览器中按F12,它将打开开发工具(Chrome,Edge)。然后,您可以复制代码并将其粘贴到控制台中,然后在此页面上运行。



您可以在此页面上看到我在哪里运行它的快照at: https://i.stack.imgur.com/V7Zvr.png



我知道你只想要PDF,但你可以从这里改变剧本。



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.


这篇关于如何从多个网页中提取链接或从同一网站打开标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆