如何使用 JQuery/JS 获取给定 url(外部 url)的网页标题 [英] How can I get the title of a webpage given the url (an external url) using JQuery/JS

查看:162
本文介绍了如何使用 JQuery/JS 获取给定 url(外部 url)的网页标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,如果这是一个愚蠢的问题,请原谅我..

I am a newbie, so excuse me if this is a silly question ..

所以我尝试的是使用 JQuery/JS 获取 URL 的标题.我不想加载url的内容然后解析其中的标签.

So what I was trying is to get the title of a URL using JQuery/JS. I dont want to load the content of the url and then parse tags in it.

让我更清楚一点,我有一组网址,比如说 20,我想显示标题..我所指的网址不是当前的网址,所以我不能使用 js document.title ..

Let me be more clear, I have a set of urls, say 20 for which I want to display the titles .. the urls i am referring to are not the current urls, so I cant use js document.title ..

所以我想做一些类似 SOMEFUNC.title(URL) 的事情并得到它的标题.有没有这样的功能?

so i want to do something of the form SOMEFUNC.title(URL) and get its title. Is there any such function?

推荐答案

您还可以使用此 API 获取任何网页的标题

You can also get the title of any webpage using this API

http://textance.herokuapp.com/title/

$.ajax({
      url: "http://textance.herokuapp.com/title/www.bbc.co.uk",
      complete: function(data) {
        alert(data.responseText);
      }
});

这篇关于如何使用 JQuery/JS 获取给定 url(外部 url)的网页标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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