Guest User

Untitled

a guest
Feb 13th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.72 KB | None | 0 0
  1.  
  2. clubland = "http://www.clublandlv.com/forum.php"
  3.  
  4.   doc = Nokogiri::HTML(open(clubland))
  5.    
  6.   doc.css("#c_cat10").each do |grab|
  7.     genres = grab.css(".forumtitle").map(&:text)
  8.     genre_links = grab.css(".forumtitle"){[:href]}
  9.    
  10.     genre_links = genre_links.map do |link|
  11.     link_id = link.children.first["href"]
  12.       CGI.parse(URI.parse(link_id).query)['f'].first.to_i
  13.   end
  14.  
  15.   DB = Sequel.connect('sqlite://clublandlv.sqlite')
  16.     # If i pass the argument to be .dinstinct matching the :genre table, i recieve a
  17.     # DISTINCT ON not supported error. If i remove the argument, duplicates are inserted.
  18.     genre_db = DB[:genres]
  19.       genre_db.import([:genre, :genre_id], genres.zip(genre_links))
  20.  
  21.  
  22. end
Advertisement
Add Comment
Please, Sign In to add comment