google_search_results 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/google_search_results.rb +15 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: feaca1e28d95b0808fb48c4071621544d402c032
|
|
4
|
+
data.tar.gz: 8bbe22d3aea6b7824a1b9a46a806d3ff5a80f45c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45b4eac6e1e4c1ad097bb0f65cb98c70c61a780580eea320a75d410ec51679806da38d7300c8948bf993da818733d79cd07ac73be35a5385e8ec78abe4362903
|
|
7
|
+
data.tar.gz: e443121731de866c2db6404fe6633a595df0e40a181b3522bd7a5c7ac8258722dd975a991e5629e7035a2b3e306119269ca3af6aa6e0c7a6317d7b2ea6f37116
|
|
@@ -6,7 +6,7 @@ require_relative 'google_search_results/hash'
|
|
|
6
6
|
|
|
7
7
|
class GoogleSearchResults
|
|
8
8
|
|
|
9
|
-
VERSION = "0.
|
|
9
|
+
VERSION = "0.2.0"
|
|
10
10
|
BACKEND = "serpapi.com"
|
|
11
11
|
|
|
12
12
|
@@serp_api_key = nil
|
|
@@ -29,14 +29,26 @@ class GoogleSearchResults
|
|
|
29
29
|
URI::HTTPS.build(host: BACKEND, path: '/search', query: URI.encode_www_form(@params))
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def get_results
|
|
33
|
+
begin
|
|
34
|
+
open(construct_url).read
|
|
35
|
+
rescue OpenURI::HTTPError => e
|
|
36
|
+
if error = JSON.load(e.io.read)["error"]
|
|
37
|
+
raise error
|
|
38
|
+
else
|
|
39
|
+
raise e
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
32
44
|
def get_html
|
|
33
45
|
@params[:output] = "html"
|
|
34
|
-
|
|
46
|
+
get_results
|
|
35
47
|
end
|
|
36
48
|
|
|
37
49
|
def get_json
|
|
38
50
|
@params[:output] = "json"
|
|
39
|
-
|
|
51
|
+
get_results
|
|
40
52
|
end
|
|
41
53
|
|
|
42
54
|
def get_hash
|