我如何编写可以在网站上找到标题的代码
How can I code something that can find the title on a website
我如何编写代码以访问网站并查找标题标签然后显示该数据?
试试这个:
HTML
<div id="hi"></div>
JS(含JQuery)
$.ajax({
url:'https://crossorigin.me/' +
'https://myurl.com',
type:'GET',
success: function(data){
var x = "";
x = data.replace(/[^]*<title>/,"");
x = x.replace(/<\/title>[^]*/,"")
$("#hi").html(x);
}
});
我如何编写代码以访问网站并查找标题标签然后显示该数据?
试试这个:
HTML
<div id="hi"></div>
JS(含JQuery)
$.ajax({
url:'https://crossorigin.me/' +
'https://myurl.com',
type:'GET',
success: function(data){
var x = "";
x = data.replace(/[^]*<title>/,"");
x = x.replace(/<\/title>[^]*/,"")
$("#hi").html(x);
}
});