Skip to content

Instantly share code, notes, and snippets.

@calindotgabriel
Created March 8, 2017 15:00
Show Gist options
  • Save calindotgabriel/ec7be1812eeb1de91aeb2017e2de176f to your computer and use it in GitHub Desktop.
Save calindotgabriel/ec7be1812eeb1de91aeb2017e2de176f to your computer and use it in GitHub Desktop.
const axios = require('axios');
const crypto = require('crypto');
const base64encode = (str) => { return new Buffer(str).toString('base64'); };
const md5hash = (str) => { return crypto.createHash('md5').update(str).digest('hex'); };
const ACCESS_KEY = "lhOqkkDQ5YDQPeXRntUd";
const SECRET_KEY = "AVY9eev3fDZaJCZvaemk";
const getApiRequestUrl = (url) => {
const request = `categories/v2/${base64encode(url)}?key=${ACCESS_KEY}`;
const signed_request = md5hash(`${SECRET_KEY}:${request}`);
return `https://api.webshrinker.com/${request}&hash=${signed_request}`
};
const getCategories = (url) => {
let request_url = getApiRequestUrl(url);
axios.get(request_url)
.then((resp) => {
let data = resp.data;
let categories = resp.data.data[0].categories;
console.log(url + " : " + categories);
})
.catch((err) => {
console.error(err);
})
};
const urls = [
"http://shop.panthers.com",
"http://www.radisson.com",
"http://www.hobby-lobby.com",
"http://www.enjoylifefoods.com",
"http://www.josephturner.co.uk",
"http://www.bedandbreakfast.com"
];
// main
urls.forEach(u => getCategories(u));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment