gsearch-parser 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/gsearch-parser.gemspec +1 -1
- data/lib/gsearch-parser.rb +14 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/gsearch-parser.gemspec
CHANGED
data/lib/gsearch-parser.rb
CHANGED
@@ -8,7 +8,12 @@ module GSearchParser
|
|
8
8
|
|
9
9
|
# Entry method for performing a web search
|
10
10
|
def GSearchParser.webSearch(query)
|
11
|
-
webSearch = GoogleWebSearch.new(query)
|
11
|
+
webSearch = GoogleWebSearch.new(query, 'QUERY')
|
12
|
+
end
|
13
|
+
|
14
|
+
# Allows directly specifing the URI of the page to parse
|
15
|
+
def GSearchParser.parseSearchPage(uri)
|
16
|
+
webSearch = GoogleWebSearch.new(uri, 'URI')
|
12
17
|
end
|
13
18
|
|
14
19
|
end
|
@@ -21,12 +26,16 @@ class GoogleWebSearch
|
|
21
26
|
@currentPage
|
22
27
|
|
23
28
|
# Class initializer
|
24
|
-
def initialize(
|
29
|
+
def initialize(arg1, flag)
|
25
30
|
# Initialize variables
|
26
31
|
@results = Array.new
|
27
32
|
|
28
|
-
|
29
|
-
|
33
|
+
case flag
|
34
|
+
when 'QUERY'
|
35
|
+
updateResults("http://google.com/search?sourceid=chrome&q=#{arg1}")
|
36
|
+
when 'URI'
|
37
|
+
updateResults(arg1)
|
38
|
+
end
|
30
39
|
|
31
40
|
# Update next URI
|
32
41
|
updateNextURI
|
@@ -45,7 +54,7 @@ class GoogleWebSearch
|
|
45
54
|
def updateResults(url)
|
46
55
|
# Fetch
|
47
56
|
searchPage = fetchPage(url)
|
48
|
-
|
57
|
+
puts url
|
49
58
|
# Store
|
50
59
|
@currentPage = searchPage
|
51
60
|
|