html 메타 태그에서 일부 메타 데이터를 추출하고 싶습니다. 다음 메타 태그가 가져온 html에 있습니다. 메타 태그에서 특성을 제목 : 유형 및 OG :cheerio : 메타 속성 선택 중 문제가 발생했습니다.
<meta property="og:type" content="offer"/>
<meta property="og:title" content='خانه ذرت با کورن داگ لذیذ و خوشمزه در تهران' />
내가 모두 OG의 내용을 얻을 수있는 아래의 샘플 코드를 작성했습니다
var request = require('request');
var cheerio = require('cheerio');
var a='http://someurl/';
getDealInfo(a);
function getDealInfo(url){
var options = {
url: encodeURI(url),
headers: {
'Accept' : '*/*',
'Cache-Control':'no-cache',
}
};
request(options, function(error, response, html){
if (!error && response.statusCode == 200) {
var $ = cheerio.load(html);
var title = $('meta[property="og:title"]').attr('content');
console.log('title: ' + title);
var type = $('meta[property="og:type"]').attr('content');
console.log('type: ' + type);
}else console.log('Error accessing Deal:' + response.statusCode + '\n'+error);
});
}
을 나는 에 대한 정확한 내용를 얻을 수 예 : 및 은 정의되지 않음og : 제목 두 속성이 모두 표시됩니다. t 가져온 된 html.
나는 왜 내가 얻을 수 없는지 알아낼 수 있습니까? og : title 속성 내용?
안녕하세요, Amir, Welcome to Stack Overflow! 문제가 정확히 무엇인지에 대한 좀 더 자세한 정보를 포함하도록 질문을 편집 할 수 있습니까? – Kezz101
사이트 소유자의 요청에 따라 기본 URL을 변경했습니다. – Amir