2017-12-11 17 views
0

私は要素は次のようになりOsmosisメタタグの情報をスクラップするにはどうすればよいですか?

を使用してメタタグのカップルの情報をこすりしようとしている:

<meta property="og:title" content="“here's the content!"> 

私はこれを使用してビデオを見ました:

tag: "meta[property='og:title']@content" 

ので、私はこのように試しました:

.find('head') 
.set({ 
    description: "meta[property='og:title']@content" 
}) 

しかし、私の小さなプロジェクトに取り組んでいない。私は本当にそれを正しく行う方法を知らない。

ご協力いただければ幸いです。

答えて

0

あなたが使用して、問題の要素をつかむことができます。

var myMeta = document.querySelector('meta[property="og:title"]'); 

をあなたがそれをつかんできたら、あなたがそのcontent値にアクセスすることができます

myMeta.content 

実施例:

var myMeta = document.querySelector('meta[property="og:title"]'); 
 

 
console.log(myMeta.content);
<meta property="og:title" content="here's the content!">

関連する問題