Advertisement
Guest User

Untitled

a guest
Feb 13th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.96 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'nokogiri'
  3. require 'open-uri'
  4. require 'sequel'
  5. require 'sqlite3'
  6. require 'pry'
  7. require 'uri'
  8. require 'cgi'
  9.  
  10.  
  11. clubland = "http://www.clublandlv.com/forum.php"
  12. doc = Nokogiri::HTML(open(clubland))
  13.  
  14.     doc.css("#c_cat10").each do |grab|
  15.       genres = grab.css(".forumtitle").map(&:text)
  16.       genre_links = grab.css(".forumtitle"){[:href]}
  17.  
  18.  
  19.   genre_links = genre_links.map do |link|
  20.     link_id = link.children.first["href"]
  21.     CGI.parse(URI.parse(link_id).query)['f'].first.to_i
  22.   end
  23.  
  24.  
  25. genres_and_links = genres.zip(genre_links)
  26. binding.pry
  27.   puts genres_and_links
  28.  
  29. =begin
  30.   Sequel.extension :core_extensions
  31.   DB = Sequel.connect('sqlite://clublandlv.sqlite')
  32.   DB.extension(:pg_array, :pg_row, :pg_hstore)
  33.  
  34.   Sequel.pg_array(genre_and_link)
  35.   binding.pry
  36.  #  genre_and_link.pg_array
  37.  #  DB[:genres].insert(:column=>Sequel.pg_array([2, 3]))
  38.  
  39.  #    main_genre.insert(:forum_id => genre_and_link)
  40. =end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement