Get meta tags from url only jQuery

Now there are a lot of scripts to get facebook data from url, but all of them work only in combination of jQuery and PHP. Is it possible to get only jQuery url?

I found here how to get the mata tags of the page:

$('meta[name=description]').attr("content");
$("meta[property=og:title]").attr("content", document.title);

But how to correctly insert this query into jQuery.get () to get text values?

$.get('http://www.imdb.com/title/tt1375666/', function(data) {
  $('meta[name=adescription]').attr("content");
});

And if the most popular sites use OpenGraph, should I look in the direction of jQuery.getJSON ()?

+5
source share
4 answers

Use html data retrieved from URL

$.get('http://www.guardian.co.uk/culture/2012/jun/21/jimmy-carr-apologises-error-tax', 
function(data) {
   $(data).find('meta[name=adescription]').attr("content");
});
+4
source

It seems that this would be impossible due to Cross Origin Policy

. API , REST API . GET https://opengraph.io/api/1.0/site/<URL encoded site URL> https://opengraph.io/

javascript.

[. . - .]

+11

!

.

$.get('http://www.guardian.co.uk/culture/2012/jun/21/jimmy-carr-apologises-error-tax', function(data) {
    $(data).filter('meta[name=adescription]').attr("content");
});   
+2

CORS Anywhere:

$.get("https://cors-anywhere.herokuapp.com/http://www.imdb.com/title/tt1375666/", function(data) {
    var meta = $(data).filter('meta[name="apple-itunes-app"]').attr("content");
    console.log(meta)
});

Used apple-itunes-appbecause it is the actual meta tag in IMDB.

+2
source

All Articles