Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
crawler4node
Advanced tools
Crawler4nodejs is an open source web crawler for Node.js which provides a simple interface for crawling the Web.
Readme
Crawler4nodejs is an open source web crawler for Node.js which provides a simple interface for crawling the Web.
npm install crawler4node
ts-node run.ts
You need to create a crawler class that extends Crawler. This class can override the _process_data()
function.
import Bot from "crawler4node"
const Cheerio = require('cheerio')
export default class MyBot extends Bot{
_process_data(url,html){
if (html && url){
const $ = Cheerio.load(html)
this.fs.appendFileSync("url.txt", url +"\n" , () => { })
let title = $(this.config.data_selector.title).text();
if (title)
this.fs.appendFileSync("test.txt", url + "\n" + title+ "\n",()=>{})
}
}
// process error url
_store_err_url(url){
this.fs.appendFileSync("error.txt", url + "\n", () => { })
}
}
let tuoi_tre_config = {
name: 'crawl-storage-1',
origin_url: 'https://tuoitre.vn',
should_visit_prefix: ['https://tuoitre.vn/'],
page_data_prefix: ['https://tuoitre.vn/'],
max_depth:3,
time_delay: 300 //3 request per seconds
data_selector:{
title: "#main-detail > div.w980 > h1"
}
};
let crawler = new MyBot(tuoi_tre_config, logger);
crawler.start();
By default there is no limit on the depth of crawling. But you can limit the depth of crawling. For example, assume that you have a seed page "A", which links to "B", which links to "C", which links to "D". So, we have the following link structure:
A -> B -> C -> D
Since, "A" is a seed page, it will have a depth of 0. "B" will have depth of 1 and so on. You can set a limit on the depth of pages that crawler4j crawls. For example, if you set this limit to 2, it won't crawl page "D". To set the maximum depth you can use:
let config = {
...
max_depth:3
};
let crawler = new ACrawler(config, logger);
Copyright (c) 2019 HongLM
FAQs
Crawler4nodejs is an open source web crawler for Node.js which provides a simple interface for crawling the Web.
The npm package crawler4node receives a total of 1 weekly downloads. As such, crawler4node popularity was classified as not popular.
We found that crawler4node 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.