-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from machenity/master
주간경향 추가. close #241
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
}]; | ||
})(), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters