30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/scrapers/nasa_apod.rb', line 30
def scrape(url=nil)
url ||= NASA_APOD_URL
apod = Hash.new
Mechanize.start do |m|
m.get url
prev = m.current_page.link_with(:text => '<').href
m.get prev
canonical = m.current_page.link_with(:text => '>' ).href
m.get canonical
m.current_page.tap do |page|
apod[:title] = page.title.strip
apod[:link] = page.uri.to_s
apod[:description] = (page/("body")).text
apod[:pubDate] = page.response['date'].to_s
apod[:guid] = page.uri.to_s
apod[:content_encoded] = (page/("body")).to_html
end
end
apod
end
|