
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
wildspider
Advanced tools
import { CrawCallbackParam, Spider, Schedule } from 'wildspider'
export default class Example extends Spider {
// 声明项目名称
project = 'example'
// 指定运行时间
@Schedule.cron('0 */1 * * * *')
start () {
const startUrl = 'http://money.163.com/'
// 使用dispatch 分配下一个任务,第一个参数为下一步要使用的方法
this.dispatch(this.index, {
url: startUrl
})
}
// age表示url有效性,指定时间内url相同的链接不会重新采集
// @Schedule.age({ minute: 2 })
index ({ req, res }: CrawCallbackParam) {
// 使用 cheerio 和使用(jQuery)一样获取内容
const $ = res.doc()
const latestNews = $('#ln_list1 li a')
latestNews.each((index, a) => {
const href = $(a).attr('href')
this.dispatch(this.detail, {
url: href
})
})
}
// age设置的很大意味着不会重新采集
@Schedule.age({ day: 1000000 })
@Schedule.returnResult('article')
async detail ({ req, res }: CrawCallbackParam) {
const $ = res.doc()
const article: any = {}
article.url = req.url
article.title = $('#epContentLeft h1').text()
const timeAndSrcNode = $('#epContentLeft .post_time_source').text()
const timeMatch = timeAndSrcNode.match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)
if (timeMatch && timeMatch.length > 0) {
article.datetime = timeMatch[0]
}
const fromMatch = timeAndSrcNode.match(/(?:来源\:)\s*(.+)\s*/)
if (fromMatch && fromMatch.length > 1) {
article.from = fromMatch[1]
} else {
article.from = '163'
}
article.content = $('#endText').html()
return article
}
}
方法需要的参数参考代码
装饰器出现在爬虫的方法上,改变其默认的行为配置
@Schedule.cron('0 */1 * * * *')
爬虫需要定时执行的方法,
只支持在start方法上
2.0 将支持任何方法(未部署)
@Schedule.returnResult('article') 将方法的返回值作为结果保存,参数为 需要保存的 【队列】 支持生成器 yiled 返回多个结果
@Schedule.age()
爬虫的有效期,有效期内相同的请求不会被重复爬取
@Schedule.faildDelay(number:second)
爬取失败后,等等x秒后重试
@Schedule.reqInterval(number:second)
每个任务之间,需要间隔 x秒
@Schedule.noWait()
每个任务之间,不需要等待,尽快执行,相当于 reqInterval(0)
@Schedule.handleNon200(codes?:number[]) 接受非200返回,默认只有返回200才认为成功,否则认为请求失败,不会进入方法体
@Schedule.timeout(timeout:number) 请求的最大超时
@Schedule.ignoreSslError() 忽略ssl证书错误
@Schedule.priority(priority:number) 任务的优先级,支持0-32,任务优先级越高,越先爬取,默认为8
FAQs
```typescript import { CrawCallbackParam, Spider, Schedule } from 'wildspider'
The npm package wildspider receives a total of 5 weekly downloads. As such, wildspider popularity was classified as not popular.
We found that wildspider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.