@xhissy/stock-market-scraper

A node package that allows you to scrape ticker info from Google Finance

Usage no npm install needed!

<script type="module">
  import xhissyStockMarketScraper from 'https://cdn.skypack.dev/@xhissy/stock-market-scraper';
</script>

README

Stock Market Scraper

A node package that allows you to scrape ticker info from Google Finance

Installation

npm install stock-market-scraper

Usage

Using .then()

const scrape = require('stock-market-scraper');

scrape('GOOGL', [afterMarket]) // After market price is a boolean. Default: true
.then(info => console.log(info));

// Result:
// {
//  companyName: 'Alphabet Inc Class A',
//  ticker: { 
//    exchange: 'NASDAQ', 
//    code: 'GOOGL'
//  },
//  price: '2,051.00',
//  stats: {
//    open: '2,076.41',
//    high: '2,077.61',
//    low: '2,032.42',
//    cap: '1.39T',
//    ratio: '32.77',
//    yield: '-',
//    previousClose: '2,100.54',
//    yearhigh: '2,145.14',
//    yearlow: '1,008.87'
//  },
//  daily: { 
//    value: '−50.54', 
//    percentage_format: '2.41%', 
//    direction: 'down' 
//  }
// }

Using async/await

const scrape = require('stock-market-scraper');

(async() => {
    const get = await scrape('GOOGL', [afterMarket]); // After market price is a boolean. Default: true
    console.log(get);
})();

// Result:
// {
//  companyName: 'Alphabet Inc Class A',
//  ticker: { 
//    exchange: 'NASDAQ', 
//    code: 'GOOGL'
//  },
//  price: '2,051.00',
//  stats: {
//    open: '2,076.41',
//    high: '2,077.61',
//    low: '2,032.42',
//    cap: '1.39T',
//    ratio: '32.77',
//    yield: '-',
//    previousClose: '2,100.54',
//    yearhigh: '2,145.14',
//    yearlow: '1,008.87'
//  },
//  daily: { 
//    value: '−50.54', 
//    percentage_format: '2.41%', 
//    direction: 'down' 
//  }
// }