Skip to content

Instantly share code, notes, and snippets.

@crayygy
Last active October 18, 2016 07:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crayygy/37fec9961a01cc77cefa5f585b9dc900 to your computer and use it in GitHub Desktop.
Save crayygy/37fec9961a01cc77cefa5f585b9dc900 to your computer and use it in GitHub Desktop.
require 'json'
require "open-uri"
puts "read file from github"
file = open('https://raw.githubusercontent.com/spacelan/wechat-emoticon/master/emoticons.json').read
emoticons = JSON.parse(file)
i=0
puts "downloading start"
emoticons.each do |emoticon|
open(emoticon["url"]) { |f|
File.open("image-#{i+=1}.gif","wb") do |file|
file.puts f.read
puts "downloading image#{i}......."
# sleep(0.5) # 减慢速度免得被ban ip,可以注释掉
end
}
end
puts "downloaded"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment