Skip to content

Instantly share code, notes, and snippets.

@cabron
Created September 18, 2011 17:28
Show Gist options
  • Save cabron/1225306 to your computer and use it in GitHub Desktop.
Save cabron/1225306 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
require 'date'
Net::HTTP.start('www.reddit.com') do |re|
1000.times do |i|
Net::HTTP.get(URI.parse 'http://www.wykop.pl/strona/'+i.to_s).scan(/span title="([^"]+)".+[\s]+z <cite><a href="([^"]+)/).each {|time, url|
data = JSON.parse(re.get('/api/info.json?url='+url).body)['data']['children'].sort {|a, b| a['data']['created'] <=> b['data']['created'] }.first
puts data['data']['title'], data['data']['url'], DateTime.strptime(time, '%Y-%m-%d %T').to_time - Time.at(data['data']['created']).getlocal("+02:00") - (Time.now.dst? ? 7200 : 3600) if data
sleep 2
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment