lib/gsearch-parser.rb in gsearch-parser-0.1.3 vs lib/gsearch-parser.rb in gsearch-parser-0.1.4
- old
+ new
@@ -30,17 +30,14 @@
'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19'))
# Iterate over each Google result list element
searchPage.css('li.g').each do |result|
# Extract the title
- title = result.css('h3').first.inner_html
+ title = result.css('h3 > a').first.inner_html
# Extract the content. There is the possibility for
# the content to be nil, so check for this
- content = result.css('span.st').first
- if !content
- content = ''
- end
+ content = result.css('span.st').first.nil? ? '' : result.css('span.st').first.inner_html
# Extract the URI
uri = result.css('cite').first.inner_html
# Create a new Result object and append to the array