gss 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +50 -42
- data/gss.gemspec +1 -1
- data/lib/gss.rb +3 -20
- data/lib/gss/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmIxYjQ5MzQ2ZDZjZmY2YWE3ZWFjM2JiYjJiNmRiYzlhZmI3ZDFhYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjlmNTJlNDQyNGZmNmVmNjU3MTUzZWY4ZDhiYmZhNWYwZDhlYjY3ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWJmZjUzZjk2MzE0ZmYzNWNmZWNjMTczMWQzMmE1NjBlZTdmZDQ1ZmU5MGJi
|
10
|
+
ZDQxYzU0M2VmMTZmMjE3M2UxNzg1ZDU0ODY3OWRmZWUzNjUxM2ZiYzRlM2Uw
|
11
|
+
MTQ4YzQyMzM3OTNhYjI5YjcxZmQ3ZDAxYTVjMDYwYmFlMjJhZWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2I3ZWY0NDJlNmJlMDFjNTBkYjI3NTkyOTEwODQwNGY5MTUwMTg0ODE1ZGFj
|
14
|
+
MjExYjRiYjQ3ODE4NWQwMTEyNjUzODQyY2ZhNjMyNWM2MGVkYWE2NGFiNzIy
|
15
|
+
NTkxOGI3M2QzMDc2NzllZmExODJkZDZlMzdlZDZkMjQ0NTA3ODI=
|
data/README.md
CHANGED
@@ -1,42 +1,50 @@
|
|
1
|
-
# Gss
|
2
|
-
|
3
|
-
This module is small but powerful if you like to webscrape. Give Gss a site and a search query and it will return the top results for your search.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'gss'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install gss
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
Here is the one line that you would want it for.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
# Gss
|
2
|
+
|
3
|
+
This module is small but powerful if you like to webscrape. Give Gss a site and a search query and it will return the top results for your search.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'gss'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install gss
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Here is the one line that you would want it for.
|
22
|
+
|
23
|
+
```
|
24
|
+
#!ruby
|
25
|
+
|
26
|
+
(top_result, top_results) = Gss.return_results("imdb.com", "Amazing Spiderman")
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
`top_result` is a Hash object has holds three values:
|
31
|
+
|
32
|
+
1. name - The name of the link.
|
33
|
+
2. url - The url to go to that site.
|
34
|
+
3. description - The short summary about what the link is about.
|
35
|
+
|
36
|
+
`top_results` is an array of Hash objects containing the top ten results
|
37
|
+
|
38
|
+
* The hash objects are the same as top_result.
|
39
|
+
* In fact `top_results[0]` would be equal to `top_result`.
|
40
|
+
* To get the second link would be `top_results[1]`
|
41
|
+
|
42
|
+
That is all that there is to it, but it is very helpful.
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( https://bitbucket.org/[my-github-username]/gss/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create a new Pull Request
|
data/gss.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'gss/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "gss"
|
8
|
-
spec.version =
|
8
|
+
spec.version = Gss::VERSION
|
9
9
|
spec.authors = ["rfitzger"]
|
10
10
|
spec.email = ["ritchiefitz1@gmail.com"]
|
11
11
|
spec.summary = %q{Grabs top google results from a given site with a given string.}
|
data/lib/gss.rb
CHANGED
@@ -18,26 +18,9 @@ module Gss
|
|
18
18
|
@search_for = search_for.gsub(" ", "+")
|
19
19
|
@gss_url = "https://www.google.com/search?q=site%3A#{@site_name}+#{@search_for}"
|
20
20
|
@noko = Nokogiri::HTML(open(@gss_url))
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# This will return a Hash object containing information about
|
26
|
-
# the top link.
|
27
|
-
#
|
28
|
-
# Access hash:
|
29
|
-
# name - link title.
|
30
|
-
# url - link to the site.
|
31
|
-
# description - short snippet about link.
|
32
|
-
#
|
33
|
-
# @return result [Hash] contains info about the top link.
|
34
|
-
def self.top_result()
|
35
|
-
result = Hash.new
|
36
|
-
result[:name] = @noko.css("li.g a")[0].text
|
37
|
-
result[:url] = "http://google.com" + @noko.css("li.g h3 a")[0]["href"]
|
38
|
-
result[:description] = @noko.css("li.g span.st")[0].text
|
39
|
-
|
40
|
-
return result
|
21
|
+
results = top_results()
|
22
|
+
|
23
|
+
return [results[0], results]
|
41
24
|
end
|
42
25
|
|
43
26
|
# This will return as array of Hash objects containing information about
|
data/lib/gss/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rfitzger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|