lib/gsearch-parser.rb in gsearch-parser-0.3.2 vs lib/gsearch-parser.rb in gsearch-parser-0.3.3
- old
+ new
@@ -27,10 +27,19 @@
# Update the results list: (Fetch, Store, and Parse)
updateResults("http://google.com/search?sourceid=chrome&q=#{query}")
end
+ # Update the nextURI attribute
+ def updateNextURI
+ # Parse next result page link from the currently marked one
+ nextPagePath = @currentPage.at_css("table#nav tr td.cur").next_sibling().at_css("a")['href']
+
+ # Construct the URI
+ @nextURI = "http://www.google.com" + nextPagePath
+ end
+
# Update the WebSearch results array by performing a Fetch, Store, Parse routine
def updateResults(url)
# Fetch
searchPage = fetchPage(url)
@@ -75,14 +84,11 @@
return currentResults
end
# Parse the results from the next page and append to results list
def nextResults
- # Parse next result page link from the currently marked one
- nextPagePath = @currentPage.at_css("table#nav tr td.cur").next_sibling().at_css("a")['href']
-
- # Construct the URI
- @nextURI = "http://www.google.com" + nextPagePath
+ # Update nextURI
+ updateNextURI
# Update results
updateResults(@nextURI)
end