Javascript 获取客户端外部页面的标题

Javascript 获取客户端外部页面的标题,javascript,jquery,html,Javascript,Jquery,Html,我的目标是在我的页面上打印外部页面的标题,而不需要在服务器端加载前者 目前,我正在使用jQuery和Google的搜索API。请注意以下解决方案的缺点: //Use google search api to get page title for link var url = "http://ajax.googleapis.com/ajax/services/search/web?q=" + **URL** + "&v=1.0&callback=?" //Set URL for l

我的目标是在我的页面上打印外部页面的标题,而不需要在服务器端加载前者

目前,我正在使用jQuery和Google的搜索API。请注意以下解决方案的缺点:

//Use google search api to get page title for link
var url = "http://ajax.googleapis.com/ajax/services/search/web?q=" + **URL** + "&v=1.0&callback=?"
//Set URL for link
$("#link").attr("href", content);
//Execute google api JSON query
$.getJSON(url, function (data) {
  //Insert the unformatted title of the first result into the page
  $("#title").append(data.responseData.results[0].titleNoFormatting);
});
^效果很好,但只适用于在谷歌上建立索引的页面,这些页面是提交URL时的第一个结果

谁能做得更好?

试试,获取标题的示例查询:

select * from html where url="http://cute-kittens.tumblr.com/" and xpath='//head/title'
您可以自己在他们的中尝试。

尝试,获取标题的示例查询:

select * from html where url="http://cute-kittens.tumblr.com/" and xpath='//head/title'

您可以自己在他们的网站上试用。

很抱歉延迟接受。YQL是一个很好的解决方案。我最终使用了他们的URL API。YQL控制台自2017年秋季以来已停止使用。你能推荐一些好的选择来获得外部页面的标题吗?提前谢谢你!很抱歉延迟接受。YQL是一个很好的解决方案。我最终使用了他们的URL API。YQL控制台自2017年秋季以来已停止使用。你能推荐一些好的选择来获得外部页面的标题吗?提前谢谢你!