Last active
May 2, 2022 23:49
-
-
Save nc7s/a08d44f08219f9c8081f936503c275c3 to your computer and use it in GitHub Desktop.
Extract front page featured articles of SCP wiki, SCP-CN, and SCP-ZH-TR
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
// Main site, https://scp-wiki.wikidot.com | |
[...document.querySelectorAll('.feature-block .content-panel')].map(p => ({ | |
feature: p.querySelector('.panel-heading').textContent.trim(), | |
title: p.querySelector('h4').textContent.trim(), | |
url: p.querySelector('h4 a').href, | |
authors: [...p.querySelectorAll('.printuser a')].map(a => ({ | |
name: a.textContent.trim(), | |
url: a.href | |
})), | |
featuredBy: p.querySelector('.panel-footer').textContent.trim().replace('Featured by ', '').replace(/and /g, '').split(', ') | |
})) | |
// SC site, http://scp-wiki-cn.wikidot.com | |
[...document.querySelectorAll('.feature-block .content-panel')].filter(p => !p.textContent.includes('最近')).map(p => ({ | |
feature: p.querySelector('.panel-heading').textContent.trim(), | |
title: p.querySelector('.feature-title').textContent.trim(), | |
url: p.querySelector('.feature-title a').href, | |
authors: [...p.querySelectorAll('.feature-subtitle .printuser a')].map(a => ({ | |
name: a.textContent.trim(), | |
url: a.href | |
})), | |
featuredBy: p.querySelector('.panel-footer').textContent.trim().replace('Featured by ', '').replace(/and /g, '').split(', ') | |
})) | |
// TC site, http://scp-zh-tr.wikidot.com | |
[...document.querySelectorAll('.feature-block .content-panel')].filter(p => !p.textContent.includes('最近')).map(p => { | |
let result = { | |
feature: p.querySelector('.panel-heading').textContent.trim(), | |
title: p.querySelector('.feature-title a').textContent.trim(), | |
url: p.querySelector('.feature-title a').href, | |
authors: [...p.querySelectorAll('.feature-subtitle .printuser a')].map(a => ({ | |
name: a.textContent.trim(), | |
url: a.href | |
})), | |
featuredBy: p.querySelector('.panel-footer').textContent.trim().replace('Featured by ', '').replace(/and /g, '').split(', ') | |
} | |
if(result.feature.includes('翻譯展出')) { | |
result.translators = result.authors | |
result.authors = [...p.querySelectorAll('.feature-title .printuser')].map(a => ({ | |
name: a.textContent.trim(), | |
url: a.href | |
})) | |
} | |
return result | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment