mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
return published date if the class name is omnivore-published-date which we added when we scraped the article
This commit is contained in:
parent
deb398112b
commit
aae6759bcb
2 changed files with 12 additions and 2 deletions
|
|
@ -652,7 +652,14 @@ async function retrieveHtml(page, logRecord) {
|
|||
document.getElementById('px-block-form-wrapper')) {
|
||||
return 'IS_BLOCKED'
|
||||
}
|
||||
|
||||
if (create_time) {
|
||||
// create_time is a global variable set by WeChat when rendering the page
|
||||
const date = new Date(create_time * 1000);
|
||||
const dateNode = document.createElement('div');
|
||||
dateNode.className = 'omnivore-published-date';
|
||||
dateNode.innerHTML = date.toLocaleString();
|
||||
document.body.appendChild(dateNode);
|
||||
}
|
||||
return document.documentElement.outerHTML;
|
||||
}, iframes);
|
||||
logRecord.puppeteerSuccess = true;
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,10 @@ Readability.prototype = {
|
|||
_checkPublishedDate: function (node, matchString) {
|
||||
// Skipping meta tags
|
||||
if (node.tagName.toLowerCase() === 'meta') return
|
||||
|
||||
// return published date if the class name is 'omnivore-published-date' which we added when we scraped the article
|
||||
if (node.className === 'omnivore-published-date' && this._isValidPublishedDate(node.textContent)) {
|
||||
return new Date(node.textContent);
|
||||
}
|
||||
// Searching for the real date in the text content
|
||||
let dateRegExpFound = this.REGEXPS.DATES_REGEXPS.find(regexp => regexp.test(node.textContent.trim()))
|
||||
dateRegExpFound && (dateRegExpFound = dateRegExpFound.exec(node.textContent.trim()))
|
||||
|
|
|
|||
Loading…
Reference in a new issue