![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
goose-parser
Advanced tools
This tool moves routine crawling process to the new level. Now it's possible to parse a web page for a moment. All you need is to specify parsing rules based on css selectors. It's so simple as Goose can do it. This library allows to parse such data types as Grid, Collections, and Simple objects. Parser has support of pagination by extension goose-paginator. Also it offers you following features: actions to interact with the page and transforms to convert parsed data to friendly format.
Now it's easy to start with Goose, just try to use goose-starter-kit for it.
yarn add goose-parser goose-phantom-environment
const Parser = require('goose-parser');
const PhantomEnvironment = require('goose-phantom-environment');
const env = new PhantomEnvironment({
url: 'https://www.google.com/search?q=goose-parser',
});
const parser = new Parser({ environment: env });
(async function () {
try {
const results = await parser.parse({
actions: [
{
type: 'wait',
timeout: 10 * 1000,
scope: '.srg>.g',
parentScope: 'body'
}
],
rules: {
scope: '.srg>.g',
collection: [[
{
name: 'url',
scope: 'h3.r>a',
attr: 'href',
},
{
name: 'text',
scope: 'h3.r>a',
}
]]
}
});
console.log(results);
} catch (e) {
console.log('Error occured:');
console.log(e.stack);
}
})();
This is a special atmosphere where Parser has to be executed. The main purpose of an environment is to provide a method for evaluating JS on the page. Goose supports following environments:
For now it's available to run goose-parser as a docker service.
Params:
Options:
There are two options to run it:
docker run -it --rm -e "DEBUG=*" redcode/goose-parser:phantom-latest 'https://www.google.com/search?q=goose-parser' '{"actions": [{"type": "wait", "scope": ".g"}], "rules": {"scope": ".g", "collection": [[{"scope": ".r>a", "name": "name"}]]}}'
Create a file rules/rules.json
which contains parser rules and run following command:
docker run -it --rm --volume="`pwd`/rules:/app/rules:ro" -e "DEBUG=*" redcode/goose-parser:phantom-latest --rules-file="/app/rules/rules.json" 'https://www.google.com/search?q=goose-parser'
Based on the code you can find detailed documentation about actions and transformations
API reference - coming soon
FAQs
Multi environment web page parser
The npm package goose-parser receives a total of 4 weekly downloads. As such, goose-parser popularity was classified as not popular.
We found that goose-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.