I browsed through SO, but what I found were examples "ho开发者_开发技巧w to manipulate a piece of html". But in my case, I want to fetch a HTML file by a given URL and just parse the websites title not the whole file.
Is there any way to do this with jQuery or any jQuery like framework?
regards,
The only way is to use a server side proxy which makes the web request and parses out the title which you can return to your page.
See a php example here
For python try the urllib
2911930 looks to have the answer
$.get("yoururl", function(response){
var theTitle = (/<title>(.*?)<\/title>/m).exec(response)[1];
alert(theTitle);
});
edit As pointed out by the commenters, you'll be restricted by SOP to pages only within your domain. And, generally, parsing HTML with regular expressions is a Bad Thing, but not too bad in this case.
精彩评论