This file contains hidden or 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
const sleep = (fn, d = 500, fail = '') => new Promise((resolve, reject) => { | |
setTimeout(() => { | |
if(fail.length) { | |
reject(fail) | |
return | |
} else { | |
resolve(fn()) | |
} | |
}, d) |
This file contains hidden or 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
/** | |
* 基于tokenizer,做页面处理 | |
*/ | |
const fs = require('fs') | |
const html = fs.readFileSync('./index.html', { | |
encoding: 'utf-8' | |
}) | |
const $ = require('cheerio').load(html, { | |
withDomLvl1: false, | |
normalizeWhitespace: false, |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="btn" >download</div> | |
<script> |
OlderNewer