module Scrapers
IMGUR.RB¶ ↑
- Author
-
Tamara Temple <tamara@tamaratemple.com>
- Since
-
2013-05-27
- Copyright
-
© 2013 Tamara Temple Web Development
- License
-
MIT
nasa_apod.rb – oneline desc
Time-stamp: <2013-10-15 00:17:15 tamara> Copyright © 2013 Tamara Temple Web Development Author: Tamara Temple <tamouse@gmail.com> License: MIT
Discussion¶ ↑
NASA’s Astronomy Picture of the Day is a great source for nice astro photos and various other information. But it isn’t something I remember to go see every day, so I’d like it to drop in my in-box or an evernote notebook. But the feed does not include the image, for some ungodly reason, so I’m adding a scraper to grab the nice info off the page including the photo.
require ‘pry’
Constants
- DESCRIPTION
- IMGUR_TEMPLATE
- LICENSE
- SUMMARY
- VERSION
- WEBSITE
Public Class Methods
agent()
click to toggle source
# File lib/scrapers.rb, line 5 def self.agent() @agent ||= Mechanize.new end
base_url(url)
click to toggle source
# File lib/scrapers.rb, line 9 def self.base_url(url) u = URI.parse(url) u.path='' u.to_s end
Public Instance Methods
imgur(url)
click to toggle source
# File lib/scrapers/imgur.rb, line 51 def imgur(url) code = File.basename(url).sub(/\.[^.]+$/,'') "http://imgur.com/download/#{code}/" end