gsearch-parser 0.3.1 → 0.3.2

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 CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gsearch-parser"
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Diego Netto"]
12
- s.date = "2012-04-15"
12
+ s.date = "2012-04-16"
13
13
  s.description = "Queries Google search and parses the resulting web page for content."
14
14
  s.email = "diegormnetto@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -17,14 +17,13 @@ end
17
17
  # Google Web Search class
18
18
  #
19
19
  class GoogleWebSearch
20
- attr_accessor :results, :currentPage
21
- @index
22
-
20
+ attr_accessor :results, :nextURI
21
+ @currentPage
22
+
23
23
  # Class initializer
24
24
  def initialize(query)
25
25
  # Initialize variables
26
26
  @results = Array.new
27
- @index = 0
28
27
 
29
28
  # Update the results list: (Fetch, Store, and Parse)
30
29
  updateResults("http://google.com/search?sourceid=chrome&q=#{query}")
@@ -78,14 +77,14 @@ class GoogleWebSearch
78
77
 
79
78
  # Parse the results from the next page and append to results list
80
79
  def nextResults
81
- # Parse next result page link
82
- nextPageUrl = @currentPage.css("table#nav tr td a")[@index]['href']
80
+ # Parse next result page link from the currently marked one
81
+ nextPagePath = @currentPage.at_css("table#nav tr td.cur").next_sibling().at_css("a")['href']
83
82
 
84
- # Increment reference index
85
- @index += 1
83
+ # Construct the URI
84
+ @nextURI = "http://www.google.com" + nextPagePath
86
85
 
87
86
  # Update results
88
- updateResults("http://www.google.com" + nextPageUrl)
87
+ updateResults(@nextURI)
89
88
  end
90
89
 
91
90
  # Iterator over results
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gsearch-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-15 00:00:00.000000000 Z
12
+ date: 2012-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri