Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# The Inflector
Our Ignition Hacks 2022 hack! Website: http://www.inflector.tech/
Our Ignition Hacks 2022 hack! Website: https://www.inflector.tech/
34 changes: 34 additions & 0 deletions docs/getInflationRate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Loading the dependencies. We don't need pretty
// because we shall not log html to the terminal
const axios = require("axios");
const cheerio = require("cheerio");
const fs = require("fs");
let value = "this";

// URL of the page we want to scrape
const url = "https://www.statcan.gc.ca/en/subjects-start/prices_and_price_indexes/consumer_price_indexes";

// Async function which scrapes the data
async function scrapeData() {
try {

// Fetch HTML of the page we want to scrape
const { data } = await axios.get(url);
// Load HTML we fetched in the previous line
const $ = cheerio.load(data);
// Select all the list items in plainlist class
const listItems = $(".indicator-growth-num-sm");

const output = listItems.children("strong").text();
value = output.substring(0, 3);

} catch (err) {
console.error(err);
}
}

function printVal() {
console.log(value);
}
// Invoke the above function
scrapeData();
Loading