Created
February 19, 2020 01:53
-
-
Save jbass86/3bde8e8d5a63ad2fbd6e822e187258a4 to your computer and use it in GitHub Desktop.
dilbert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const get = require("simple-get"); | |
const cheerio = require('cheerio') | |
const pad = function(num) { | |
if (num < 10) { | |
return "0" + num; | |
} else { | |
return num; | |
} | |
} | |
let current = new Date(); | |
let url = `https://dilbert.com/strip/${current.getFullYear()}-${pad(current.getMonth() + 1)}-${pad(current.getDate())}` | |
console.log("url is " + url); | |
get.concat(url, (error, response, data) => { | |
if (error) { | |
console.log("there was error"); | |
console.log(error); | |
return; | |
} | |
let $ = cheerio.load(data.toString()); | |
let thing = $(".img-comic-container img"); | |
let imageURL = "http:" + thing[0].attribs.src; | |
console.log(imageURL); | |
get.concat(imageURL, (error, response, imageData) => { | |
console.log(imageData); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment