Permalink
Browse files

Use classic Minuteman record lookup as the newer system seems to be o…

…mitting locations entirely.
  • Loading branch information...
1 parent cb35c05 commit 1ba95b65ffc34236930cffcce66b53cb5cf39568 @thegreatape committed Feb 6, 2012
@@ -13,7 +13,7 @@ def find(title, author)
def fetch(uri)
headers ||= {}
uri = URI::parse(uri)
- req = Net::HTTP::Get.new(uri.path+'?'+uri.query, {'@cookies' => @cookies})
+ req = Net::HTTP::Get.new(uri.path+'?'+(uri.query||''), {'@cookies' => @cookies})
res = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(req)
}
@@ -37,16 +37,22 @@ def normalize_status(s)
when /available/i
return "In"
else
- return s
+ return "Out"
end
end
def get_locations(row)
- (row/'table.itemTable tr' ).map { |loc|
- tds = loc/'td'
- [(tds[0]/'a').inner_html.strip.split("/").map(&:titleize)[0..-2].join(' / '),
- tds[2].inner_html.strip.scan(/^(\w+).*/).first.first.titleize] unless tds.empty?
- }.reject(&:nil?)
+ link = (row/'.dpBibTitle a')[0]
+ return [] unless link
+ href = link.attributes['href']
+ id = CGI::unescape(href).match(/C\|R([^\|]*)\|S/)[1]
+ res = fetch("http://library.minlib.net/record=#{id}").body
+ File.open("#{Rails.root}/test/fixtures/search_bots/minuteman_bot/gardens_of_the_moon_records.html", 'w') {|f| f.write(res) }
+ (Hpricot(res)/'table.bibItems .bibItemsEntry').map do |row|
+ tds = row/'td'
+ [(tds[0]/'a').inner_html.strip.split("/").map(&:titleize)[0..-2].join(' / '),
+ tds[2].inner_html.strip.scan(/^(?:<!-- field % -->&nbsp;)(\w+).*/).first.first.titleize] unless tds.empty?
+ end.reject(&:nil?)
end
def search_url(title, author)
Oops, something went wrong.

0 comments on commit 1ba95b6

Please sign in to comment.