lib/recochoku-chart.rb
##
# Given a URL, scrapes track titles and artists from HTML source
# and creates an array of RecochokuRank objects with it
# 
# Params:
# => url - the url whose source will be scrapped
# 
# Returns:
# =>  rank_list - array of RecochokuRanks
##
Given a URL, scrapes track titles and artists from HTML source
and creates an array of RecochokuRank objects with it

> url - the url whose source will be scrapped


Given a URL scrapes track titles and artists from HTML source and creates an array of RecochokuRank objects with it > url - the url whose source will be scrapped
def url_to_ranks(url)
    utr_agent = Mechanize.new
    rank_list, title_list, artist_list = [], [], []
    utr_agent = utr_agent.get(url)
    utr_agent.search('td.info a.ttl').children.each do |c|
      title_list.push(c.text)
    end
    utr_agent.search('td.info p a:not(:has(img))').children.each do |d|
      artist_list.push(d.text)
    end
    0.upto(49) do |i|
      rank_list.push(RecochokuRank.new((i + 1).to_s, title_list[i], artist_list[i]))
    end
    return rank_list
  end
def url_to_ranks ( url ) utr_agent = Mechanize . new rank_list , title_list , artist_list = [ ] , [ ] , [ ] utr_agent = utr_agent . get ( url ) utr_agent . search ( 'td.info a.ttl' ) . children . each do | c | title_list . push ( c . text ) end utr_agent . search ( 'td.info p a:not(:has(img))' ) . children . each do | d | artist_list . push ( d . text ) end 0 . upto ( 49 ) do | i | rank_list . push ( RecochokuRank . new ( ( i + 1 ) . to_s , title_list [ i ] , artist_list [ i ] ) ) end return rank_list end
Given a URL, scrapes track titles and artists from HTML source
and creates an array of RecochokuRank objects with it
Given a URL scrapes track titles and artists from HTML source and creates an array of RecochokuRank objects with it
# Track titles # Artist titles
url
<not_specific>