0225172 43ad53e14d feat: update | vor 4 Monaten | |
---|---|---|
.. | ||
.gitignore | vor 4 Monaten | |
README.md | vor 4 Monaten | |
href.js | vor 4 Monaten | |
import.js | vor 4 Monaten | |
package-lock.json | vor 4 Monaten | |
package.json | vor 4 Monaten |
右键,分析目标站点,同类DOM值的selector特点
字符串特征:href="/gushi/shi/586.html"
let ElArray = document.querySelectorAll(".main-content a")
let list = []
for(let i=0;i<ElArray.length;i++){
list[i] = ElArray[i]
}
// HTMLElement 转换成 href字符串 "https://www.gushicimingju.com/gushi/shi/113.html"
console.log("DOM选择后,数量:",list.length)
list = list.map(el=>el.href)
// 过滤符合特征的链接地址
list = list.filter(item=>(item?.indexOf("/gushi/shi/")>-1))
console.log("字符过滤后,数量:",list.length)
// 将list数据保存至href.js
https://www.npmjs.com/package/cheerio
npm i cheerio -S