gsearch-parser 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gsearch-parser"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
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"]
@@ -29,11 +29,22 @@ class GoogleSearch
29
29
  searchPage = Nokogiri::HTML(open("http://google.com/search?sourceid=chrome&q=#{query}",
30
30
  'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19'))
31
31
 
32
- # Iterate over each Google result list element and extract data
32
+ # Iterate over each Google result list element
33
33
  searchPage.css('li.g').each do |result|
34
- title = result.css('h3').first.content
34
+ # Extract the title
35
+ title = result.css('h3').first.inner_html
36
+
37
+ # Extract the content. There is the possibility for
38
+ # the content to be nil, so check for this
35
39
  content = result.css('span.st').first
36
- uri = result.css('cite').first
40
+ if !content
41
+ content = ''
42
+ end
43
+
44
+ # Extract the URI
45
+ uri = result.css('cite').first.inner_html
46
+
47
+ # Create a new Result object and append to the array
37
48
  @results << Result.new(title, content, uri)
38
49
  end
39
50
  end
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.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: