Created
April 16, 2014 11:22
-
-
Save saboyutaka/10855876 to your computer and use it in GitHub Desktop.
booth_link.coffee
This file contains 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
util = require('util') | |
cheerio = require('cheerio') | |
# Reply booth items title and image_link | |
module.exports = (robot) -> | |
robot.hear /#(https:\/\/\w+.booth.pm\/items\/\d+)/, (msg) -> | |
msg | |
.http(msg.match[1]) | |
.get() (err, res, body) -> | |
if res.statusCode != 200 | |
msg.send "Couldn't access BOOTH." | |
else | |
$ = cheerio.load(body) | |
title = $('title').text() | |
primary_image = $('.photo-gallery img').first().attr('src') | |
msg.send title + '\n' + primary_image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment