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.
listtojson
Advanced tools
Readme
An npm module for node.js to convert HTML lists to JSON objects. Basically ordered and unordered lists are the same. Just the browser treats them differently in rendering bullets or numbers I decided to not differenciate between them and just provide a package for all of them.
This package can be passed the markup for a single list as a string, a fragment of HTML or an entire page or just a URL (with an optional callback function; promises also supported).
The response is always an array. Every array entry in the response represents a list found on the page (in same the order they were found in the HTML).
Install via npm
npm install listtojson
convertUrl
)'use strict';
const listtojson = require('listtojson');
listtojson.convertUrl(
'https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes',
function(listsAsJson) {
console.log(listsAsJson[1]);
}
);
convert
)Have a look in the tests folder.
'use strict';
const listtojson = require('../lib/listtojson');
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, '../test/lists.html'), {encoding: 'UTF-8'});
const converted = listtojson.convert(html);
console.log(converted);
convertUrl
)If you need to get data from a remote server to pass it to the parser you can call listtojson.convertUrl
.
When working behind a proxy you can pass any request-options (proxy, headers,...) by adding a request
object to the options passed to convertUrl
.
for more information on how to configure request please have a look at:
https://github.com/request/request
listtojson.convertUrl('https://www.timeanddate.com/holidays/ireland/2017', {
useFirstRowForHeadings: true,
request: {
proxy: 'http://proxy:8080'
}
});
Array of classes to find a specific list using this css class. Default is 'null/undefined'.
The id of the list which is to be fetched provided as a string. Default is 'null/undefined'.
Improvements, fixes and suggestions for better written modules that other people have created are welcome, as are bug reports against specific tables it is unable to handle.
You can find basic tests in the test folder. I implemented the most straight forward way in using the library. Nonetheless there are some edge cases that need to be tested and I would like to ask for support here. Feel free to fork and create PRs here. Every bit of help is appreciated.
If you submit a pull request, please add an example for your use case, so I can understand what you want it to do (as I want to get around to writing tests for this and want to understand the sort of use cases people have).
FAQs
An npm module for node.js to convert HTML lists to JSON objects
The npm package listtojson receives a total of 2,134 weekly downloads. As such, listtojson popularity was classified as popular.
We found that listtojson 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.