Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$('td div').each(function () {
const text = entities.decodeHTML5($(this).html());
const date = text.split(/\[조식\]|\[중식\]|\[석식\]/)[0].replace('<br>', '').trim();
/*
[예시]
'3 <br>[중식]고등어' =(1)=> '3 <br>' =(2)=> '3 ' =(3)=> '3'
[설명]
(1) 텍스트 '[조식]' 또는 '[중식]' 또는 '[석식]' 중 하나를 기준으로 나눈 배열의 첫 번째 원소를 고름
(2) 첫 번째 원소의 <br> 태그를 제거함
(3) 문자의 공백을 제거함
*/
if (date/* 날짜 정보가 있는 경우에만 배열에 식단을 저장함 */) {
const breakfast = /\[조식\](.*?)(\[|$)/g.exec(text) && /\[조식\](.*?)(\[|$)/g.exec(text)[1];
/*
[예시]
'[조식]고등어<br>참치[' => '고등어<br>참치'
[설명]
function encodeAllStrings(obj) {
for (var k in obj) {
if (typeof obj[k] == "object") {
encodeAllStrings(obj[k]);
} else {
if (!obj.hasOwnProperty(k)) {
continue; // skip this property
}
if (typeof(obj[k]) == 'string'){
// decode HTML entities after decoding the charset
// otherwise we would end up with a string with mixed encoding
obj[k] = decodeHTML5(encodeText(charset, obj[k]));
}
}
}
}
$aScope.find('[itemprop]').each(function() {
var $el = cheerio(this);
var scope = $el.attr('itemscope');
if (typeof scope !== 'undefined') {
return;
}
var $parentScope = $el.parents('[itemscope]');
if (!($parentScope.attr('itemtype').indexOf(videoObjectSchema) > -1)) {
return;
}
var key = $el.attr('itemprop');
if (key) {
var value = decodeHTML5(decode($el.attr('content') || $el.attr('href')));
result[key] = value;
}
});
get attributes() {
if (this._attrs)
return this._attrs;
this._attrs = {};
var attrs = this.rawAttributes;
for (var key in attrs) {
this._attrs[key] = entities.decodeHTML5(attrs[key]);
}
return this._attrs;
},
breakfast: day.breakfast.map(menu => entities.decodeHTML5(menu)),
lunch: day.lunch.map(menu => entities.decodeHTML5(menu)),
get text() {
return entities.decodeHTML5(this.rawText);
},
getMeta: function(dailymailVideo, decode) {
return {
title: decodeHTML5(decode(dailymailVideo.title)),
description: decodeHTML5(decode(dailymailVideo.descr))
}
},
parser.write(data)
for(
var skipLevel = 1;
readability._getCandidateNode().info.textLength < 250 && skipLevel < 4;
skipLevel++
){
readability.setSkipLevel(skipLevel)
handler.restart()
}
var article = readability.getArticle()
article.url = url
article.title = entities.decodeHTML5(article.title).trim()
article.html = entities.decodeHTML5(article.html.replace(/\s+/g, ' ')).trim()
article.text = readability.getText(readability._getCandidateNode()).trim()
return article
}
getData: function(cheerio, decode) {
var $img = cheerio('#comic img');
var $a = cheerio('#comic a');
return {
xkcd_data: {
image: $img.attr('src'),
has_large_image: $a.length,
description: decodeHTML5(decode($img.attr('title')))
}
};
},
$aScope.find('[itemprop]').each(function() {
var $el = cheerio(this);
var scope = $el.attr('itemscope');
if (typeof scope !== 'undefined') {
return;
}
var key = $el.attr('itemprop');
if (key) {
var value = decodeHTML5(decode($el.attr('content') || $el.attr('href')));
result[key] = value;
}
});