-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
3,494 additions
and
197 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,90 @@ | ||
<p align="center"> | ||
<img width="256" src='https://Hamud.PJ568.eu.org/zh-Hans-CN/favicon.svg'/> | ||
</p> | ||
|
||
> 🌏简体中文 | [繁體中文](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=chinese_traditional) | [日本語](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=japanese) | [한어](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=korean) | [English](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=english) | [Español](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=spanish) | ||
> 🗃️[Github](//github.com/Hamud-Lang/Hamud_Book) | [Gitee](//gitee.com/Hamud-Lang/Hamud_Book) | ||
# <img width="30" style="margin: -3px 5px;" src="https://Hamud.PJ568.eu.org/zh-Hans-CN/favicon.svg"/>哈姆语言之书 | ||
|
||
* 本项目旨在为哈姆语提供标准范本。为学习哈姆语的人提供参考资料和交流平台。 | ||
* 假若您对本项目感到满意,请在您的指尖星空[绘制一颗新的星🌟](//github.com/Hamud-Lang/Hamud_Book),指引我们继续砥砺前行。 | ||
* [点击访问](//Hamud.PJ568.eu.org/index.html) | ||
|
||
## 🪴项目活动 | ||
|
||
`暂时不可用` | ||
|
||
## 📖其他说明 | ||
|
||
* `本项目使用的开源项目允许修改,但请保留原作者信息。确需去除,请联系作者,以免失去技术支持。`详情请参照许可证。 | ||
* 出现 BUG 请提出 `Issue` ,我会修复。 | ||
* 期待您的 `Commitment` 。 | ||
|
||
## 🏆贡献者们 | ||
|
||
> 感谢所有让这个项目变得更好的贡献者们! | ||
[![Contributors Chart](//contrib.rocks/image?repo=Hamud-Lang/Hamud_Book)](//github.com/Hamud-Lang/Hamud_Book/graphs/contributors) | ||
<a href="tencent://message/?uin=2918044071&Menu=yes" target="_blank"><img width="64" alt="UrnEn" src="https://q1.qlogo.cn/g?b=qq&nk=2918044071&s=640"/></a> | ||
<a href="https://space.bilibili.com/3461580048042619" target="_blank"><img width="64" alt="希腊火Onerio" src="https://q1.qlogo.cn/g?b=qq&nk=1480900845&s=640"/></a> | ||
<a href="tencent://message/?uin=2301299437&Menu=yes" target="_blank"><img width="64" alt="kh1Y3Ynquu" src="https://q1.qlogo.cn/g?b=qq&nk=2701152452&s=640"/></a> | ||
<a href="tencent://message/?uin=93618119&Menu=yes" target="_blank"><img width="64" alt="宁宁" src="https://q1.qlogo.cn/g?b=qq&nk=93618119&s=640"/></a> | ||
<a href="tencent://message/?uin=8598225&Menu=yes" target="_blank"><img width="64" alt="平A新的病毒" src="https://q1.qlogo.cn/g?b=qq&nk=8598225&s=640"/></a> | ||
|
||
## 💻代码或内容贡献 | ||
|
||
欢迎每一位对本项目感兴趣的朋友贡献代码和内容。 | ||
|
||
较为简单的提交贡献方法可查阅[贡献文档](//Hamud.PJ568.eu.org/zh-Hans-CN/Contribute/)以了解相关信息。 | ||
|
||
在提交代码前请确保您了解 [mdbook](//rust-lang.github.io/mdBook/) 系统。 | ||
|
||
### 参考 | ||
|
||
* Fork 源码,下载到本地并运行项目; | ||
* 添加/修改代码; | ||
* <b style="color:red">⚠️对相关改动进行全面的自我测试⚠️</b>; | ||
* 确认无误后提交修改到 Github; | ||
* 提交 Pull Request; | ||
|
||
### 请注意 | ||
|
||
* 单次 Pull Request 不应提交过多修改,请确保每次提交都针对特定的功能且务必说明本次改动的具体目的,例如:修复某 bug 、优化某方法 等,方便进行 Code Review; | ||
* 对于 bug 的修复,应该将本次 Pull Request 和相对应 bug 的 issue 关联起来,让别人知道该问题已经被修复; | ||
* 对于较大的新功能,你需要先提交 Issues,例如 “添加 XXX 功能”,确认该功能有被添加的必要后,再开始工作; | ||
* 对于一些主观的样式、交互逻辑调整:如颜色、图标的使用,某些预设配置的增减修改等,一般不予通过。但可以在 Discussions 中进行讨论; | ||
* 其他如简单的代码优化、文档修正等,只要修改合理都会被接受。 | ||
|
||
## 📄许可证 | ||
|
||
本项目遵循 [CC BY-SA 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/) 许可协议。如果想了解完整许可信息,请查阅 `LICENSE` 文件。 | ||
|
||
### 🗃️附加许可证 | ||
|
||
* hack:[MIT license](https://mit-license.org); | ||
* [Github](https://github.com/egoist/hack/blob/master/LICENSE); | ||
* Character_substitution:[Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0); | ||
* [Github](https://github.com/Hamud-Lang/Character_substitution/LICENSE)、[Gitee](https://gitee.com/Hamud-Lang/Character_substitution/LICENSE); | ||
* translate:[Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0); | ||
* [Github](https://github.com/sandoche/Darkmode.js/LICENSE); | ||
* darkmode.js:[MIT license](//mit-license.org); | ||
* [Github](https://github.com/xnx3/translate/blob/master/LICENSE)、[Gitee](https://gitee.com/mail_osc/translate/blob/master/LICENSE); | ||
* msg:[Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0); | ||
* [Github](https://github.com/xnx3/msg/blob/master/LICENSE)、[Gitee](https://gitee.com/mail_osc/msg/blob/master/LICENSE); | ||
* giscus:[MIT license](//mit-license.org); | ||
* [Github](https://github.com/giscus/giscus/blob/main/LICENSE)。 | ||
|
||
## ⭐Star 历史 | ||
|
||
<a href="https://star-history.com/#Hamud-Lang/Hamud_Book&Date"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Hamud-Lang/Hamud_Book&type=Date&theme=dark" /> | ||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Hamud-Lang/Hamud_Book&type=Date" /> | ||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Hamud-Lang/Hamud_Book&type=Date" /> | ||
</picture> | ||
</a> | ||
<p align="center"> | ||
<img width="256" src='https://Hamud.PJ568.eu.org/zh-Hans-CN/favicon.svg'/> | ||
</p> | ||
|
||
> 🌏简体中文 | [繁體中文](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=chinese_traditional) | [日本語](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=japanese) | [한어](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=korean) | [English](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=english) | [Español](//hamud.pj568.eu.org/zh-Hans-CN/About_Book.html?language=spanish) | ||
> 🗃️[Github](//github.com/Hamud-Lang/Hamud_Book) | [Gitee](//gitee.com/Hamud-Lang/Hamud_Book) | ||
# <img width="30" style="margin: -3px 5px;" src="https://Hamud.PJ568.eu.org/zh-Hans-CN/favicon.svg"/>哈姆语言之书 | ||
|
||
* 本项目旨在为哈姆语提供标准范本。为学习哈姆语的人提供参考资料和交流平台。 | ||
* 假若您对本项目感到满意,请在您的指尖星空[绘制一颗新的星🌟](//github.com/Hamud-Lang/Hamud_Book),指引我们继续砥砺前行。 | ||
* [点击访问](//Hamud.PJ568.eu.org/index.html) | ||
|
||
## 🪴项目活动 | ||
|
||
`暂时不可用` | ||
|
||
## 📖其他说明 | ||
|
||
* `本项目使用的开源项目允许修改,但请保留原作者信息。确需去除,请联系作者,以免失去技术支持。`详情请参照许可证。 | ||
* 出现 BUG 请提出 `Issue` ,我会修复。 | ||
* 期待您的 `Commitment` 。 | ||
|
||
## 🏆贡献者们 | ||
|
||
> 感谢所有让这个项目变得更好的贡献者们! | ||
[![Contributors Chart](//contrib.rocks/image?repo=Hamud-Lang/Hamud_Book)](//github.com/Hamud-Lang/Hamud_Book/graphs/contributors) | ||
<a href="tencent://message/?uin=2918044071&Menu=yes" target="_blank"><img width="64" alt="UrnEn" src="https://q1.qlogo.cn/g?b=qq&nk=2918044071&s=640"/></a> | ||
<a href="https://space.bilibili.com/3461580048042619" target="_blank"><img width="64" alt="希腊火Onerio" src="https://q1.qlogo.cn/g?b=qq&nk=1480900845&s=640"/></a> | ||
<a href="tencent://message/?uin=2301299437&Menu=yes" target="_blank"><img width="64" alt="kh1Y3Ynquu" src="https://q1.qlogo.cn/g?b=qq&nk=2701152452&s=640"/></a> | ||
<a href="tencent://message/?uin=93618119&Menu=yes" target="_blank"><img width="64" alt="宁宁" src="https://q1.qlogo.cn/g?b=qq&nk=93618119&s=640"/></a> | ||
<a href="tencent://message/?uin=8598225&Menu=yes" target="_blank"><img width="64" alt="平A新的病毒" src="https://q1.qlogo.cn/g?b=qq&nk=8598225&s=640"/></a> | ||
|
||
## 💻代码或内容贡献 | ||
|
||
欢迎每一位对本项目感兴趣的朋友贡献代码和内容。 | ||
|
||
较为简单的提交贡献方法可查阅[贡献文档](//Hamud.PJ568.eu.org/zh-Hans-CN/Contribute/)以了解相关信息。 | ||
|
||
在提交代码前请确保您了解 [mdbook](//rust-lang.github.io/mdBook/) 系统。 | ||
|
||
### 参考 | ||
|
||
* Fork 源码,下载到本地并运行项目; | ||
* 添加/修改代码; | ||
* <b style="color:red">⚠️对相关改动进行全面的自我测试⚠️</b>; | ||
* 确认无误后提交修改到 Github; | ||
* 提交 Pull Request; | ||
|
||
### 请注意 | ||
|
||
* 单次 Pull Request 不应提交过多修改,请确保每次提交都针对特定的功能且务必说明本次改动的具体目的,例如:修复某 bug 、优化某方法 等,方便进行 Code Review; | ||
* 对于 bug 的修复,应该将本次 Pull Request 和相对应 bug 的 issue 关联起来,让别人知道该问题已经被修复; | ||
* 对于较大的新功能,你需要先提交 Issues,例如 “添加 XXX 功能”,确认该功能有被添加的必要后,再开始工作; | ||
* 对于一些主观的样式、交互逻辑调整:如颜色、图标的使用,某些预设配置的增减修改等,一般不予通过。但可以在 Discussions 中进行讨论; | ||
* 其他如简单的代码优化、文档修正等,只要修改合理都会被接受。 | ||
|
||
## 📄许可证 | ||
|
||
本项目遵循 [CC BY-SA 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/) 许可协议。如果想了解完整许可信息,请查阅 `LICENSE` 文件。 | ||
|
||
### 🗃️附加许可证 | ||
|
||
* hack:[MIT license](https://mit-license.org); | ||
* [Github](https://github.com/egoist/hack/blob/master/LICENSE); | ||
* Character_substitution:[Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0); | ||
* [Github](https://github.com/Hamud-Lang/Character_substitution/LICENSE)、[Gitee](https://gitee.com/Hamud-Lang/Character_substitution/LICENSE); | ||
* translate:[Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0); | ||
* [Github](https://github.com/sandoche/Darkmode.js/LICENSE); | ||
* darkmode.js:[MIT license](//mit-license.org); | ||
* [Github](https://github.com/xnx3/translate/blob/master/LICENSE)、[Gitee](https://gitee.com/mail_osc/translate/blob/master/LICENSE); | ||
* msg:[Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0); | ||
* [Github](https://github.com/xnx3/msg/blob/master/LICENSE)、[Gitee](https://gitee.com/mail_osc/msg/blob/master/LICENSE); | ||
* giscus:[MIT license](//mit-license.org); | ||
* [Github](https://github.com/giscus/giscus/blob/main/LICENSE)。 | ||
|
||
## ⭐Star 历史 | ||
|
||
<a href="https://star-history.com/#Hamud-Lang/Hamud_Book&Date"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Hamud-Lang/Hamud_Book&type=Date&theme=dark" /> | ||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Hamud-Lang/Hamud_Book&type=Date" /> | ||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Hamud-Lang/Hamud_Book&type=Date" /> | ||
</picture> | ||
</a> | ||
|
||
<!-- mdbook build | mdbook serve --> | ||
<!-- python ./assets/MHDH_cpy.py --> |
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,94 @@ | ||
import os | ||
import requests | ||
import re | ||
from bs4 import BeautifulSoup | ||
|
||
# pip install requests | ||
# pip install beautifulsoup4 | ||
|
||
def save_section_content(url, path, domain): | ||
# 发送 GET 请求获取网页内容 | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
|
||
# 解析网页内容 | ||
soup = BeautifulSoup(response.text, 'html.parser') | ||
|
||
# 删除指定的元素 | ||
for element_id in ['cosmos-header-interlang', 'cosmos-articleHeader-actions', 'printfooter', 'cosmos-content-additionalContent', 'CosmosRailWrapper']: | ||
element = soup.find('div', {'id': element_id}) or soup.find('span', {'id': element_id}) | ||
if element: | ||
element.decompose() | ||
|
||
# 获取 <section id="mw-content"> 元素 | ||
section = soup.find('section', {'id': 'mw-content'}) | ||
|
||
# 处理内容内域名 | ||
section = replace_href_domain(section, domain) | ||
|
||
if section: | ||
# 获取网页标题 | ||
title = soup.title.string.strip() | ||
# 替换无效的文件名字符 | ||
title = title.replace('/', '-').replace('\\', '-').replace(':', '-').replace('*', '-').replace('?', '-').replace('"', "'").replace('<', '[').replace('>', ']') | ||
|
||
# 构造保存的文件路径 | ||
save_path = os.path.join(path, f'{title}.md') | ||
|
||
# 保存 <section> 元素内的内容到文件 | ||
with open(save_path, 'w', encoding='utf-8') as file: | ||
file.write(section.prettify()) | ||
|
||
print(f'内容已保存到文件:{save_path}') | ||
else: | ||
print('未找到指定的 <section id="mw-content"> 元素') | ||
|
||
def replace_href_domain(content, domain): | ||
|
||
# 查找所有 <a> 标签 | ||
for a in content.find_all('a', href=True): | ||
# 获取 href 属性的值 | ||
href = a['href'] | ||
# 如果 href 属性的值以 / 开头,则替换为指定域名 | ||
if href.startswith('/'): | ||
a['href'] = f'{domain}{href}' | ||
|
||
# 返回修改后的 HTML 内容 | ||
return content | ||
|
||
def batch_remove_string_in_filename(folder_path, target_string): | ||
for root, dirs, files in os.walk(folder_path): | ||
for file_name in files: | ||
if target_string in file_name: | ||
new_file_name = file_name.replace(target_string, '') | ||
os.rename(os.path.join(root, file_name), os.path.join(root, new_file_name)) | ||
|
||
# 执行 | ||
path = './src/World_line/' | ||
domain = '//mhdh.pj568.eu.org' | ||
# Hamud | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/%E5%93%88%E5%A7%86', path, domain) | ||
# Index | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/MHDH%E4%B8%96%E7%95%8C%E7%BA%BF', path, domain) | ||
# Languages | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/%E8%AF%AD%E8%A8%80%E5%88%97%E8%A1%A8', path, domain) | ||
# Graph | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/%E6%89%80%E6%9C%89%E5%9B%BE%E4%BE%8B', path, domain) | ||
# Nations | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/MHDH%E7%8E%B0%E5%AD%98%E5%9B%BD%E5%AE%B6%E5%88%97%E8%A1%A8', path, domain) | ||
# HIL | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/HITL%E4%B8%96%E7%95%8C%E7%BA%BF', path, domain) | ||
# 哈姆民族 | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/%E5%93%88%E5%A7%86%E6%B0%91%E6%97%8F%E5%88%97%E8%A1%A8', path, domain) | ||
# 哈姆文化 | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/%E5%93%88%E5%A7%86%E6%96%87%E5%8C%96%E5%88%97%E8%A1%A8', path, domain) | ||
# 哈姆方言 | ||
save_section_content('https://mhdh.pj568.eu.org/wiki/%E5%93%88%E5%A7%86%E6%96%B9%E8%A8%80%E5%88%97%E8%A1%A8', path, domain) | ||
|
||
batch_remove_string_in_filename(path, ' - MHDH维基') | ||
|
||
# save_section_content('#####', path, domain) | ||
# save_section_content('#####', path, domain) | ||
# save_section_content('#####', path, domain) | ||
# save_section_content('#####', path, domain) | ||
# save_section_content('#####', path, domain) |
Oops, something went wrong.