Skip to content

Instantly share code, notes, and snippets.

@kevindavis
Created October 23, 2013 20:13
Show Gist options
  • Save kevindavis/7125875 to your computer and use it in GitHub Desktop.
Save kevindavis/7125875 to your computer and use it in GitHub Desktop.
grabs emoji codes and filenames out of the emoji-cheat-sheet.com page and dumps them into a string designed to be pasted into the Yammer emoticon processing stuff
#!/usr/bin/env ruby
# USAGE: ./scraper.rb emoji-cheat-sheet.com/public/index.html | pbcopy
# need to check out emoji-cheat-sheet from github
# ==> https://github.com/arvida/emoji-cheat-sheet.com
filename = ARGV[0]
file = File.new(filename, "r")
while (line = file.gets)
# example line:
# <li><div><img src="graphics/emojis/bowtie.png"> :<span class="name">bowtie</span>:</div></li>
match = line.match(/emojis\/(.*\.png).*name">(.*?)</)
unless match.nil?
# example output designed to be pasted into emoticon.js eg.
# , ['cat.gif', 'Cat face', ['(@)']]
path = match[1]
name = match[2].sub(/_/, " ").split.each {|s| s.capitalize!}.join(" ")
key = ":" + match[2] + ":"
print ", ['" + path + "', '" + name + "', ['" + key + "']]\n"
end
end
file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment