maxthyen / table-scraper Goto Github PK
View Code? Open in Web Editor NEWSimple utility for scraping data from html tables on a given website into a list of javascript objects
License: MIT License
Simple utility for scraping data from html tables on a given website into a list of javascript objects
License: MIT License
tried with multiple examples
$ mkdir table-scraper-test
$ cd table-scraper-test
$ npm init -y
Wrote to...
$ npm i table-scraper
=== npm audit security report ===
# Run npm update is-my-json-valid --depth 5 to resolve 2 vulnerabilities
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ is-my-json-valid │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > har-validator > │
│ │ is-my-json-valid │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/76 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ is-my-json-valid │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > har-validator > │
│ │ is-my-json-valid │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/572 │
└───────────────┴──────────────────────────────────────────────────────────────┘
# Run npm update sshpk --depth 5 to resolve 1 vulnerability
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ sshpk │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > http-signature > │
│ │ sshpk │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/606 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hawk │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=3.1.3 < 4.0.0 || >=4.1.1 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > hawk │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/77 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ ReDoS via long string of semicolons │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ tough-cookie │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=2.3.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > tough-cookie │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/130 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ tough-cookie │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=2.3.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > tough-cookie │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/525 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Remote Memory Exposure │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ request │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=2.68.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/309 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > hawk > boom > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > hawk > cryptiles > │
│ │ boom > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > hawk > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ > 4.2.0 < 5.0.0 || >= 5.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > hawk > sntp > hoek │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/566 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.17.5 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > cheerio > lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/577 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.17.11 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > cheerio > lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/782 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.17.12 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > cheerio > lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1065 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Memory Exposure │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ bl │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.9.5 <1.0.0 || >=1.0.1 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > bl │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/596 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Memory Exposure │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ tunnel-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.6.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > tunnel-agent │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/598 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Out-of-bounds Read │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ stringstream │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.0.6 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > stringstream │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/664 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ extend │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=2.0.2 <3.0.0 || >=3.0.2 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > extend │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/996 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Insufficient Entropy │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ cryptiles │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.1.2 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > hawk > cryptiles │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1464 │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Prototype Pollution Protection Bypass │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ qs │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=6.0.4 <6.1.0 || >=6.1.2 <6.2.0 || >=6.2.3 <6.3.0 || │
│ │ >=6.3.2 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ table-scraper │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ table-scraper > tabletojson > request > qs │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1469 │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 20 vulnerabilities (2 low, 12 moderate, 6 high) in 238 scanned packages
run `npm audit fix` to fix 3 of them.
17 vulnerabilities require manual review. See the full report for details.
These are all caused by dependence on the out of date [email protected]
. This package should be updated.
First, this is a great tool, thank you. I was using it for a class and found that if a page has a table that has the same headings then only data in the last column with the same heading is returned.
Example: https://www.forex.com/en-us/support/margin-requirements
`
var scrapermargin = require('table-scraper');
scrapermargin
.get('https://www.forex.com/en-us/support/margin-requirements')
.then(function(tableData ) {
console.log('Margin Rates');
var tjf = tableData;
console.log(tjf);
});
`
The function returns only the last two columns of the table:
$ node app.js
Margin Rates
[ [ { 'Currency Pair': 'AUD/JPY', MMR: '4%' },
{ 'Currency Pair': 'CAD/CHF', MMR: '3%' },
{ 'Currency Pair': 'EUR/AUD', MMR: '3%' },
.... ] ]
The Margin Requirements table on Forex.com has a table with:
Currency Pair | MMR | Currency Pair | MMR | Currency Pair | MMR |
---|---|---|---|---|---|
AUD/CAD | 3% | AUD/CHF | 3% | AUD/JPY | 4% |
AUD/NZD | 3% | AUD/USD | 3% | CAD/CHF | 3% |
CAD/JPY | 4% | CHF/JPY | 4% | EUR/AUD | 3% |
Currently is still returning the home page instead
If I scrape a table on a page that has headers of the same name, it ignores the second header and doesn't include it in the scraped JSON object.
I would like use this package in react-native, but react-native is giving error: crypto module not found in haste map. when i tried to install crypto i found it has been deprecated and built into node.js,
https://markets.ft.com/data/equities/tearsheet/historical?s=ANL:KAR
This page is giving me data for 'Date' and 'Volume' columns twice, but in different formats. A bit of research shows that it is because they have one format for desktop devices and another for the mobile devices.
here is one row that is returned (see Date and Volume are returned twice):
{ Date: 'Monday, June 12, 2017Mon, Jun 12, 2017',
Open: '12.70',
High: '12.70',
Low: '11.82',
Close: '12.10',
Volume: '6,826,0006.83m' }
How can i fix this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.