Skip to content

Commit

Permalink
Merge pull request #341 from machenity/master
Browse files Browse the repository at this point in the history
주간경향 추가. close #241
  • Loading branch information
disjukr authored Jun 29, 2019
2 parents e5db845 + 55ca201 commit bc80497
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export const readyToParse = () => waitElement('#comments');
* [x] [전자신문](http://www.etnews.com)
* [x] [조선비즈](http://biz.chosun.com)
* [x] [조선일보](http://www.chosun.com)
* [x] [주간경향](http://weekly.khan.co.kr)
* [x] [중앙데일리](http://koreajoongangdaily.joins.com)
* [x] [중앙일보](http://joongang.joins.com)
* [x] [지디넷코리아](http://www.zdnet.co.kr)
Expand Down
46 changes: 46 additions & 0 deletions src/impl/주간경향.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as $ from 'jquery';

import {
Article,
ReadyToParse,
} from '..';
import {
clearStyles,
} from '../util';


export const readyToParse: ReadyToParse = wait => wait('#articleBody');

export const cleanup = () => $('#scrollDiv, iframe').remove();

export function parse(): Article {
const title = $('.title')[0].cloneNode(true);
const reporter = $('.byline_wrap', title);
reporter.remove();
const reporterText = reporter.text();
return {
title: (() => {
return $(title).text().trim();
})(),
content: (() => {
const articleBodyElement = $('.article_txt')[0].cloneNode(true) as HTMLElement;
return clearStyles(articleBodyElement).innerHTML;
})(),
timestamp: (() => {
const times = $('.article_date');
return {
created: new Date(times[0].childNodes[0].textContent!.trim().replace(/\./g, "-")),
};
})(),
reporters: (() => {
if (!reporterText) {
return [];
}
const seperator = reporterText.lastIndexOf(" ");
return [{
name: reporterText.substr(0, seperator),
mail: reporterText.substr(seperator),
}];
})(),
};
}
1 change: 1 addition & 0 deletions src/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default {
'전자신문': ['www.etnews.com/*'],
'조선비즈': ['biz.chosun.com/site/data/html_dir/*'],
'조선일보': ['news.chosun.com/site/data/html_dir/*'],
'주간경향': ['weekly.khan.co.kr/khnm.html?*'],
'중앙데일리': ['koreajoongangdaily.joins.com/news/article/article.aspx*'],
'중앙일보': ['joongang.joins.com/article/*', 'article.joins.com/news/article/article.asp*', 'news.joins.com/article/*'],
'지디넷코리아': ['www.zdnet.co.kr/view/?no=*'],
Expand Down

0 comments on commit bc80497

Please sign in to comment.