Class: FindArt::AlbumArtExchange

Inherits:
Scraper show all
Defined in:
lib/FindArt/scrapers/albumartexchange.rb

Instance Method Summary collapse

Methods inherited from Scraper

#find_art, register_scraper, registerd_sites, #scrapers, unregister_scrapers!

Instance Method Details

#scrape(artist, title, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/FindArt/scrapers/albumartexchange.rb', line 6

def scrape(artist,title,opts={})
  url = nil    
  search_url =  "#{@@url}#{CGI.escape("#{artist} #{title}")}"
  browser = WWW::Mechanize.new    
  browser.get(search_url) do |page|
    doc = Hpricot(page.body)    
    element =  doc.at("* table tr td a img[@width='150']")
    src = element["src"] if !element.nil? && !element["src"].nil?
    if src
      path = src.split("src=").last
      url = "http://www.albumartexchange.com#{URI.decode(path)}"      
    end
  end
 url
end