google_search_results 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/google_search_results.rb +37 -0
- data/lib/google_search_results/hash.rb +18 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4be11b8f4cd10f3ceebf0c3cba8f9f71cbaa5e64
|
4
|
+
data.tar.gz: bdcc25442a55c75c51902b55f48e1f72a56fe104
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0be283b7a34891c4575331dc811609abf3a4386cf5b139ef41b497a2ea200ea9f85a6c39ef6e6ab1cb856bb85b7dc337751b212de20f903e4edea3b3e885333f
|
7
|
+
data.tar.gz: 7bd32b47260fb9ba7c86ce3252fa4dd88b92ddcb822e7161a90ce830520cff8a0942ac8722c6b5a6c0edfe199ddd45dd32d8cea8038dbde4f6dc5ca9ad737e59
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'open-uri'
|
4
|
+
require 'json'
|
5
|
+
require_relative 'google_search_results/hash'
|
6
|
+
|
7
|
+
class GoogleSearchResults
|
8
|
+
|
9
|
+
VERSION = "0.0.1"
|
10
|
+
BACKEND = "serpapi.com"
|
11
|
+
|
12
|
+
attr_accessor :params
|
13
|
+
|
14
|
+
def initialize params
|
15
|
+
@params = params
|
16
|
+
end
|
17
|
+
|
18
|
+
def construct_url
|
19
|
+
@params[:source] = "ruby"
|
20
|
+
URI::HTTPS.build(host: BACKEND, path: '/search', query: URI.encode_www_form(@params))
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_html
|
24
|
+
@params[:output] = "html"
|
25
|
+
open(construct_url).read
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_json
|
29
|
+
@params[:output] = "json"
|
30
|
+
open(construct_url).read
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_hash
|
34
|
+
JSON.load(get_json).symbolize_all_keys
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Hash
|
2
|
+
def symbolize_all_keys(hash=self)
|
3
|
+
symbolized_hash = {}
|
4
|
+
return hash if hash.is_a?(String)
|
5
|
+
hash.each do |k, v|
|
6
|
+
if v.is_a?(Array)
|
7
|
+
symbolized_hash[k.to_sym] = v.map do |e|
|
8
|
+
symbolize_all_keys(e)
|
9
|
+
end
|
10
|
+
elsif v.is_a?(Hash)
|
11
|
+
symbolized_hash[k.to_sym] = symbolize_all_keys(v)
|
12
|
+
else
|
13
|
+
symbolized_hash[k.to_sym] = v
|
14
|
+
end
|
15
|
+
end
|
16
|
+
symbolized_hash
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_search_results
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hartator
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.2'
|
41
|
+
description: Get Google Search Results via SERP API. Hash, JSON, and HTML outputs
|
42
|
+
supported.
|
43
|
+
email: hartator@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/google_search_results.rb
|
49
|
+
- lib/google_search_results/hash.rb
|
50
|
+
homepage: https://github.com/serpapi/google-search-results-ruby
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.9.2
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.6.14
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Google Search Results via SERP API.
|
74
|
+
test_files: []
|