Fetch meta-tags from url only by jQuery

前端 未结 4 1596
时光说笑
时光说笑 2021-01-13 05:35

Now a lot of scripts to facebook-style fetching data from url, but all of them work only in combination of jQuery and PHP. Is it possible to fetch url only by jQuery?

<
4条回答
  •  滥情空心
    2021-01-13 06:22

    It's possible using 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-app because it's an actual meta tag on IMDB.

提交回复
热议问题