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