musicscrape 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/musicscrape.rb +17 -4
- metadata +1 -1
data/lib/musicscrape.rb
CHANGED
@@ -1,17 +1,29 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rest-client'
|
3
3
|
#This gem goes to www.thestranger.com/seattle/Music and scrapes data for all the recommended concerts.
|
4
|
-
#The
|
4
|
+
#The one method you need is get_music_listings which returns an array of hashes of the form
|
5
|
+
#[[:title=> "", :venue=>"", :date=>"", :details=>""], ...]
|
6
|
+
#how to use this gem:
|
7
|
+
#scrape = Scrape.new
|
8
|
+
#scrape.get_music_listings
|
9
|
+
#that is all.
|
5
10
|
|
6
11
|
|
7
12
|
class Scrape
|
8
13
|
#Scrape is meant to parse www.thestranger.com/music and pull out info on the recommended shows
|
9
14
|
#initialize with source_type = :web and url = "http://www.thestranger.com/music"
|
10
|
-
def initialize(source_type
|
15
|
+
def initialize(source_type = :web)
|
11
16
|
@source_type = source_type
|
12
|
-
@url
|
17
|
+
@url="http://www.thestranger.com/seattle/Music"
|
13
18
|
end
|
14
|
-
|
19
|
+
|
20
|
+
def get_music_listings
|
21
|
+
#This is the one method you need to use
|
22
|
+
@scrape = Scrape.new(:web)
|
23
|
+
@pruned_page = @scrape.remove_excess(@scrape.load_page)
|
24
|
+
@scrape.get_events(@pruned_page) #returns an array of hashes
|
25
|
+
end
|
26
|
+
|
15
27
|
def load_page
|
16
28
|
#Uses RestClient to get the html
|
17
29
|
if @source_type == :web then
|
@@ -58,6 +70,7 @@ class Scrape
|
|
58
70
|
end
|
59
71
|
|
60
72
|
class Google
|
73
|
+
#the plan is to make it add the events to your google calendar. Not yet Functional.
|
61
74
|
attr_writer :password
|
62
75
|
attr_writer :user
|
63
76
|
attr_writer :title
|