Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
I'm a fan of Python library BeautifulSoup. It's feature-rich and very easy to use. But when I am working on a small react-native project, and I tried to find a HTML parser library
like BeautifulSoup, I failed.
So I want to write a HTML parser library which can be so easy to use just like BeautifulSoup in Javascript.
JSSoup uses tautologistics/node-htmlparser as HTML dom parser,
and creates a series of BeautifulSoup like API on top of it.
JSSoup supports both node and react-native.
JSSoup tries to use the same interfaces as BeautifulSoup so BeautifulSoup user can use JSSoup seamlessly.
However, JSSoup uses Javascript's camelCase naming style instead of Python's underscore naming style.
Such as find_all()
in BeautifulSoup is replaced as findAll()
.
$ npm install jssoup
//react-native
import JSSoup from 'jssoup';
// nodejs
var JSSoup = require('jssoup').default;
var soup = new JSSoup('<html><head>hello</head></html>');
var soup = new JSSoup('<html><head>hello</head></html>');
var tag = soup.find('head');
tag.name
// 'head'
tag.name = 'span'
console.log(tag)
//<span>hello</span>
var soup = new JSSoup('<tag id="hi" class="banner">hello</tag>');
var tag = soup.nextElement;
tag.attrs
// {id: 'hi', class: 'banner'}
tag.attrs.id = 'test';
console.log(tag)
// <tag id="test" class="banner">hello</tag>
var data = `
<div>
<a>1</a>
<b>2</b>
<c>3</c>
</div>
`
var soup = new JSSoup(data);
var div = soup.nextElement;
var b = div.nextElement.nextElement;
// b.string: '2'
var a = b.previousElement;
// a.string: '1'
var soup = new JSSoup(data);
var div = soup.nextElement;
var a = div.nextElement;
var b = a.nextSibling;
var c = b.nextSibling;
c.nextSibling == undefined;
div.contents
// [<a>1</a>, <b>2</b>, <c>3</c>]
div.descendants
// [<a>1</a>, 1, <b>2</b>, 2, <c>3</c>, 3]
div.parent == soup
b.extract();
div.contents
// [<a>1</a>, <c>3</c>]
b.extract();
div.append(b)
div.contents
// [<a>1</a>, <c>3</c>, <b>2</b>]
var data = `
<div>
<div class="h1"></div>
<a>hello</a>
</div>
`
var soup = new JSSoup(data);
soup.findAll('a')
// [<a>hello</a>]
soup.findAll('div', 'h1')
// [<div class="h1"></div>]
var data = `
<div>
<p> hello </p>
<p> world </p>
</div>
`
var soup = new JSSoup(data);
soup.find('p')
// <p> hello </p>
var soup = new JSSoup('<html><head>hello</head></html>');
soup.nextElement.prettify()
// <html>
// <head>
// hello
// </head>
// </html>
div.text
// '123'
div.getText('|')
// '1|2|3'
b.string == '2';
var soup = new JSSoup('<html><head>hello</head></html>');
soup.string == 'hello';
npm test
There's a lot of work need to be done.
FAQs
JSSoup is a BeautifulSoup style HTML parser library.
The npm package jssoup receives a total of 4,883 weekly downloads. As such, jssoup popularity was classified as popular.
We found that jssoup 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
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.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.