apify-js

编程之家收集整理的这个编程导航主要介绍了apify-js编程之家,现在分享给大家,也给大家做个参考。

apify-js

apify-js 介绍

apify-js是一款用于 JavaScript 的可伸缩的 web 爬虫和抓取库。能通过无头(headless)Chrome 和 Puppeteer 实现数据提取和 Web 自动化作业的开发。  它提供了管理和自动扩展无头Chrome / Puppeteer实例池的工具,维护要爬网的URL队列,将爬网结果存储到本地文件系统或云端。

安装:

npm install apify --save

运行以下示例以使用Puppeteer执行网站的爬取:

const Apify = require('apify');

Apify.main(async () => {

const requestQueue = await Apify.openRequestQueue();

await requestQueue.addRequest({ url: 'https://www.iana.org/' });

const pseudoUrls = [new Apify.PseudoUrl('https://www.iana.org/[.*]')];

const crawler = new Apify.PuppeteerCrawler({

requestQueue,

handlePageFunction: async ({ request,page }) => {

const title = await page.title();

console.log(`Title of ${request.url}: ${title}`);

await Apify.utils.puppeteer.enqueueLinks(page,'a',pseudoUrls,requestQueue);

},

maxRequestsPerCrawl: 100,

maxConcurrency: 10,

});

await crawler.run();

});

网站地址:https://sdk.apify.com/

GitHub:https://github.com/apifytech/apify-js

网站描述:可伸缩的 web 爬虫和抓取库

apify-js官方网站

官方网站:https://sdk.apify.com/

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

johnny-five,Bocoup 的 JavaScript 机器和物联网编程框架
WePY,一款让小程序支持组件化开发的框架
Deep playground,神经网络的交互式可视化,使用d3.js和TypeS...
ShareDB,用于并发编辑系统的前端数据库
RxJS,RxJS 是使用 Observables 的响应式编程的库
egg-react-ssr,最小而美的Egg + React + SSR 服务端渲染应用...