Skip to content

Instantly share code, notes, and snippets.

@michaelfward
Created May 6, 2015 16:53
Show Gist options
  • Save michaelfward/86a59553a64ec9d06830 to your computer and use it in GitHub Desktop.
Save michaelfward/86a59553a64ec9d06830 to your computer and use it in GitHub Desktop.
Pulls image URLs from Tumblr Posts pulled from the API. Programmed for a twitter robot.
def get_html file
regex = /.*(media.*\.jpg)/
fd = File.open("./img/#{file}", "r")
fd.each_line do |line|
if (regex =~ line) == 0
data = Regexp.last_match
puts data[1]
end
end
end
files = Dir.entries('./img')
files.each do |file|
unless file[0] == '.'
get_html file
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment