diff --git a/README.md b/README.md index b348cfbd..b1f18025 100644 --- a/README.md +++ b/README.md @@ -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) diff --git "a/src/impl/\354\243\274\352\260\204\352\262\275\355\226\245.ts" "b/src/impl/\354\243\274\352\260\204\352\262\275\355\226\245.ts" new file mode 100644 index 00000000..96e25aa9 --- /dev/null +++ "b/src/impl/\354\243\274\352\260\204\352\262\275\355\226\245.ts" @@ -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), + }]; + })(), + }; +} diff --git a/src/sites.ts b/src/sites.ts index db2e72e0..6ce37125 100644 --- a/src/sites.ts +++ b/src/sites.ts @@ -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=*'],