Guest User

Untitled

a guest
Feb 11th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.25 KB | None | 0 0
  1. require 'nokogiri'
  2. require 'open-uri'
  3. require 'sequel'
  4. require 'sqlite3'
  5. require 'pry'
  6.  
  7. clubland = "http://www.clublandlv.com/forum.php"
  8.  
  9. doc = Nokogiri::HTML(open(clubland))
  10.  
  11. puts doc.css('title').text
  12. puts
  13.  
  14.  
  15. doc.css("#cat10").each do |grab|
  16.   genres = grab.css(".forumtitle").map(&:text)
  17.   genreslink = grab.css(".forumtitle"){[:href]}
  18.   subgenre = grab.css(".subforum a").map(&:text)
  19.   subgenrelink = grab.css(".subforum a"){[:href]}
  20.    
  21.  
  22.   puts "This is an array of the genres:"
  23.   puts genres
  24.   puts
  25.   puts "These are the genre links:"
  26.   puts genreslink
  27.   puts
  28. #  puts "This is an array of the subgenres:"
  29. #  puts subgenre
  30. #  puts
  31. #  puts "These are the subgenre links:"
  32. #  puts subgenrelink
  33.  
  34.   genreslink.each do |genrelink|
  35.     cuts = genreslink.attribute("href")
  36.     cuts.split("?f")
  37.     cuts.split("&")
  38.     puts cuts
  39.     genrelink;
  40.  
  41.    
  42. # Table has 3 columns. ID(auto), genre, forum_id
  43.  
  44. #Connects to the local DB
  45.         DB = Sequel.connect('sqlite://clublandlv.sqlite')
  46. # Create a dataset
  47.         main_genre = DB[:genres]
  48. # Insert the results
  49.   genres.each do |genre|
  50.     main_genre.insert(:genre => genre)
  51.    # unless db_has_genre?
  52.     genre;
  53.        
  54.    
  55.  
  56.  
  57.  
  58.         end    
  59.       end    
  60.   end
Advertisement
Add Comment
Please, Sign In to add comment