Puppeteer-Fetchbot: 基于JSON-API的网站交互及数据提取工具
FetchBot 是一个基于 Node.js Puppeteer 的库和命令行工具,它提供了一个简单的 JSON-API,用于在任何网站上执行类似人类的交互和数据提取。
FetchBot 的功能:
- 自动化网站交互: 模拟人类用户在网站上的操作,例如点击、输入、滚动等。
- 数据提取: 从网站页面中提取结构化数据,并将其转换为易于处理的 JSON 格式。
工作原理:
FetchBot 通过扩展数据获取的方式工作,它将浏览器视为一个事件驱动的系统。用户可以定义一系列事件监听器,当特定 URL 或正则表达式与当前页面 URL 匹配时,触发相应的操作。
示例代码:
const myFetchBotInstance = new FetchBot({ attached: true });
let resultFromEvent = myFetchBotInstance.goto('https://example.com')
.then(() => {
return myFetchBotInstance.eventEmitter.emit('example.com', { // event definition with data
doSomethingSpecial: true
});
})
.then(result => { // you can chain as many steps as you like
// result now contains all data you've extracted during the event(s)
});
82.97KB
文件大小:
评论区