Skip to content

Instantly share code, notes, and snippets.

View DseidLi's full-sized avatar

Mo Li DseidLi

  • Tsinghua University, Shanghai AI Lab
  • Shenzhen, Shanghai
  • 06:15 (UTC +08:00)
View GitHub Profile
@DseidLi
DseidLi / download_csdn_article.js
Created May 12, 2024 21:06
使用JavaScript提取CSDN文章并保存为HTML文件
// 打开一个新窗口以便于存放和显示提取的内容
var newWin = window.open('', '_blank');
// 提取带有'blog-content-box'类的元素的HTML内容
var contentBox = document.querySelector('.blog-content-box').outerHTML;
// 获取标题用于文件名
var articleTitle = document.querySelector('#articleContentId').innerText.trim();
var fileName = articleTitle.replace(/[\/\\:*?"<>|]/g, '_') + '.html'; // 清理文件名中的非法字符