Skip to content

Commit

Permalink
update something
Browse files Browse the repository at this point in the history
  • Loading branch information
helongfei authored and helongfei committed Sep 15, 2022
1 parent 223fd58 commit 8d03c7a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion generateOutline.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function main() {
continue
}
const path = process.argv[2]+'/'+item
const filename = path.split('/').pop().replace('.pdf','').replace("something",'')
const filename = path.split('/').pop().replace('.pdf','').replace("【daobanke.com】",'')
// .replace(/\d{2}/,'')
const pdf = await PDFDocument.load(fs.readFileSync(path))
console.log(filename+" "+page)
Expand Down
4 changes: 3 additions & 1 deletion html2pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async function captureToPDF(browser, url, pdfOutputDir) {
await page.close();
} catch (err) {
console.error(`error when capturing ${url}, error message: ${err.message}`);
console.error('ERR_INVALID_URL, 表示使用的是相对路径,请使用绝对路径;因为chromium运行相对路径会找不到文件')
}
}

Expand All @@ -37,7 +38,8 @@ async function main(){

const urls = fs.readdirSync(process.argv[2])

const browser = await puppeteer.launch();
// true 表示后台运行 chromium, false 表示前台运行 chromium
const browser = await puppeteer.launch({headless:true});

for (var url of urls) {
if (url == ".DS_Store"){
Expand Down
8 changes: 6 additions & 2 deletions remove_invalid_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function main(){
return
}
const content = remove_html(parse(fs.readFileSync(process.argv[2]+'/'+item)))
// todo 新文件名
item = item.replace('something','')
fs.writeFileSync(process.argv[3]+"/"+item,content)
console.log(item)
})
Expand All @@ -33,8 +35,10 @@ function remove_html(root){
// 分割线
root.querySelector("._2SACi4xg_0").remove()
// 音频
root.querySelector("._1Bg5E78Y_0").innerHTML="<br>"
root.querySelector("._1Bg5E78Y_0").setAttribute("class","")
if (root.querySelector("._1Bg5E78Y_0") != null){
root.querySelector("._1Bg5E78Y_0").innerHTML="<br>"
root.querySelector("._1Bg5E78Y_0").setAttribute("class","")
}
// 尾图
const imgs = root.querySelector("._29HP61GA_0").querySelectorAll("p").length
if (imgs > 1){
Expand Down

0 comments on commit 8d03c7a

Please sign in to comment.