Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
scrape-brrr
Advanced tools
Simple web page scraping.
yarn add scrape-brrr
*The following examples use typescript style import. For plain nodejs, use
const { scrape } = require('scrape-brrr')
/**
* <body>
* <div>
* <span>
* <p>sentence 1</p>
* <p>sentence 2</p>
* <p>sentence 3</p>
* </span>
* </div>
* <p>footer</p>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', 'div p:not(:first-child)')
// ["sentence 2", "sentence 3"]
/**
* <body>
* <div>Best wof</div>
* <span>Largest wof</span>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', [
{
name: 'stats',
selector: 'div',
},
{
name: 'another-stats',
selector: 'span',
},
])
// {
// stats: "Best wof"
// "another-stats": "Largest wof"
// }
/**
* <body>
* <div>
* <span class="name">husky</span>
* <span class="name">golden</span>
* </div>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', [{
name: 'bestWofs',
selector: 'div .name',
many: true
}])
// { bestWofs: ["husky", "golden"] }
/**
* <body>
* <div>
* <span class="name">husky</span>
* <span class="name">golden</span>
* </div>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', [{
name: 'bestWofs',
selector: 'div',
many: true,
nested: [
{
name: 'name',
selector: 'span',
}
]
}])
// {
// bestWofs: [
// { name: "husky" },
// { name: "golden" },
// ]
// }
/**
* <body>
* <span class="title" id="best">Best wof</div>
* <a href="/other-stats">other stats</a>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', [
{
name: 'key',
selector: 'span',
attr: 'id'
},
{
name: 'otherLink',
selector: 'a',
attr: 'href'
},
])
// {
// key: "best",
// otherLink: "/other-stats"
// }
/**
* <body>
* <div>
* <span class="rank">1</span>
* <span class="name">husky</span>
* </div>
* <div>
* <span class="rank">2</span>
* <span class="name">golden</span>
* </div>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', [{
name: 'best',
selector: 'div',
many: true,
nested: [
{
name: 'rank',
selector: '.rank',
},
{
name: 'name',
selector: '.name',
}
],
transform: arr => arr[0]
}])
// {
// best: { name: "husky" },
// }
Use puppeteer to load page with javascript to scrape dynamic content.
/**
* <body>
* <h1>
* tick tok tick tok
* </h1>
* <script>
* document.querySelector('h1').textContent = 'boom!'
* </script>
* </body>
*/
import { scrape } from 'scrape-brrr'
const data = await scrape('http://website.com', 'h1', { dynamic: true })
// ["boom!"]
big5
)yarn install
yarn test
FAQs
Simple web page scraping
We found that scrape-brrr 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.