Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
parse and transform streaming html using css selectors
input html:
<table>
<tbody>blah blah blah</tbody>
<tr><td>there</td></tr>
<tr><td>it</td></tr>
<tr><td>is</td></tr>
</table>
var trumpet = require('trumpet');
var tr = trumpet();
tr.pipe(process.stdout);
var ws = tr.select('tbody').createWriteStream();
ws.end('<tr><td>rawr</td></tr>');
var fs = require('fs');
fs.createReadStream(__dirname + '/html/table.html').pipe(tr);
output:
<table>
<tbody><tr><td>rawr</td></tr></tbody>
<tr><td>there</td></tr>
<tr><td>it</td></tr>
<tr><td>is</td></tr>
</table>
input html:
<html>
<head>
<title>beep</title>
</head>
<body>
<div class="a">¡¡¡</div>
<div class="b">
<span>tacos</span>
<span> y </span>
<span>burritos</span>
</div>
<div class="a">!!!</div>
</body>
</html>
var trumpet = require('trumpet');
var tr = trumpet();
tr.selectAll('.b span', function (span) {
span.createReadStream().pipe(process.stdout);
});
var fs = require('fs');
fs.createReadStream(__dirname + '/html/read_all.html').pipe(tr);
output:
tacos y burritos
var trumpet = require('trumpet')
Create a new trumpet stream. This stream is readable and writable.
Pipe an html stream into tr
and get back a transformed html stream.
Parse errors are emitted by tr
in an 'error'
event.
Return a result object elem
for the first element matching selector
.
Get a result object elem
for every element matching selector
.
When the selector for elem
matches, query the case-insensitive attribute
called name
with cb(value)
.
When the selector for elem
matches, replace the case-insensitive attribute
called name
with value
.
If the attribute doesn't exist, it will be created in the output stream.
Create a new readable stream with the inner html content under elem
.
Create a new write stream to replace the inner html content under elem
.
Create a new readable writable stream that outputs the content under elem
and
replaces the content with the data written to it.
Presently these css selectors work:
With npm do:
npm install trumpet
MIT
FAQs
parse and transform streaming html using css selectors
The npm package trumpet receives a total of 6,717 weekly downloads. As such, trumpet popularity was classified as popular.
We found that trumpet 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.