RyaneMax af5339d161 fix: update shige schema | 4 months ago | |
---|---|---|
.. | ||
.gitignore | 4 months ago | |
README.md | 4 months ago | |
href.js | 4 months ago | |
import.js | 4 months ago | |
package-lock.json | 4 months ago | |
package.json | 4 months ago |
右键,分析目标站点,同类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