Skip to content

Instantly share code, notes, and snippets.

@morrillt
Created April 8, 2012 15:46
Show Gist options
  • Save morrillt/2338068 to your computer and use it in GitHub Desktop.
Save morrillt/2338068 to your computer and use it in GitHub Desktop.
1st proj
# typhoeus by paul dix
def hello
puts "hello"
end
hello
require 'rubygems'
require 'json'
require 'net/http'
require 'rest_client'
require 'nokogiri'
require 'net/http'
url = 'http://api.reddit.com/r/dogfort.json'
response = RestClient.get(url)
newobject = JSON.parse(response)
# newobject['data']['children'].each { |dogurl| dogurl['data']['url'] NEED TO ADD CLOSING }
dogurl = newobject['data']['children'][0]['data']['url']
response = RestClient.get(dogurl)
doc = Nokogiri::HTML(response.body)
blip = doc.css('img')
# puts blip.inspect
doc.css("img").each do |node|
# node.src
puts "looking up imgs"
imgurl = node['src']
response = RestClient.get imgurl, :accept => 'image/jpeg'
puts response.headers
resonse.headers.inspect
# conn = Net::HTTP.start(imgurl)
# conn.head('/').each_header do |k,v|
# puts "#{k} = #{v}"
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment