Skip to content

Commit

Permalink
Merge pull request #340 from malkoG/hot-fix/fix-mediatoday
Browse files Browse the repository at this point in the history
미디어오늘 수정
  • Loading branch information
disjukr authored Jun 29, 2019
2 parents e502b1f + c38b9e5 commit e5db845
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/impl/미디어오늘.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import * as $ from 'jquery';
import { clearStyles } from '../util';
import { Article, Timestamp } from '..';
import { ReadyToParse, Article, Timestamp } from '..';

export const cleanup = () => {
$('#scrollDiv').remove();
}

export const readyToParse: ReadyToParse = wait => wait('.view-editors');

export function parse(): Article {
return {
title: $('#font_title').text().trim(),
subtitle: $('#font_subtitle').text(),
title: $('.article-head-title').eq(0).text().trim(),
subtitle: $('.article-head-sub').eq(0).text(),
content: (() => {
const content = $('#media_body')[0].cloneNode(true);
$('.ad_lumieyes_area', content).each((_, el) => {
$(el).closest('tr').remove();
});
const content = $('#article-view-content-div')[0].cloneNode(true);
$('.ad-template', content).remove();
$('.article-sponsor', content).remove();
$('form[name=support_paypal_form]', content).remove();
$('.view-editors', content).remove();
return clearStyles(content).innerHTML;
})(),
timestamp: (() => {
let data: Timestamp = {};
$('td[align="left"] table td', $('#font_email').closest('table').closest('td').closest('table')).text().split(/(입력|노출)\s*:([\d\-\.\s:]+)/).forEach(function (v, i, arr) {
if (v === '입력')
data.created = new Date(arr[i + 1].trim().replace(/\s+/g, ' ').replace(/[-\.]/g, '/') + '+0900');
else if (v === '노출')
data.lastModified = new Date(arr[i + 1].trim().replace(/\s+/g, ' ').replace(/[-\.]/g, '/') + '+0900');
});
return data;
let data: string = $('div.info-text>ul>li').eq(1).text().substr(3).trim();
data = data.replace(/\./g, '-');
data = data.replace(/\s/g, 'T');
return {
created: new Date(data),
};
})(),
reporters: (() => {
const parsedData = $('#font_email').text().split('|');
const parsedData = $('div.info-text>ul>li')[0];
return [{
name: parsedData[0].trim(),
mail: parsedData[1].trim()
name: parsedData.childNodes[0].textContent!.trim(),
mail: parsedData.childNodes[1].childNodes[0].textContent!.trim()
}];
})()
};
Expand Down

0 comments on commit e5db845

Please sign in to comment.