search_cli 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/search.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31c9ecae7f1852cf651c90c46e4c7198ff35764aa54733e762bebfa84df2d6b0
|
4
|
+
data.tar.gz: 62cca8c62d0b32661174dae7da35bd62a5ce8501ac033387fcea328fa051605d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 883c3ae8e79df0e3c51d2f792b6e518fd291b3f3257fa039fc85c08791804d393832861d5fc2884742957f7d874192027a647deee54bbdff96ef3d91b6675113
|
7
|
+
data.tar.gz: 5baee7c866618b5faf03e166990c995ea37f376a9ad795e30e6c1eaa885424732d0500d45b325477bf7291adf647371afabf5345e59fbf145eb6ed42c7657bf8
|
data/lib/search.rb
CHANGED
@@ -6,19 +6,26 @@ require_relative './display_module'
|
|
6
6
|
|
7
7
|
class SearchProviders
|
8
8
|
def self.bing(keyword)
|
9
|
+
Display.before_result
|
9
10
|
res = RestClient.get 'https://bing.com/search/', params: { q: keyword }
|
10
11
|
tags = Nokogiri::HTML.parse(res).xpath('//li[@class="b_algo"] //h2 //a')
|
11
12
|
tags.each do |tag|
|
12
13
|
Display.tags tag
|
13
14
|
end
|
15
|
+
Display.after_result
|
14
16
|
end
|
15
17
|
|
16
18
|
def self.gems(keyword)
|
19
|
+
Display.before_result
|
17
20
|
res = RestClient.get "https://rubygems.org/search?utf8=%E2%9C%93&query=#{keyword}"
|
18
21
|
tags = Nokogiri::HTML.parse(res).xpath('//a[@class="gems__gem"]')
|
19
22
|
tags.each do |tag|
|
23
|
+
if tag[:href].start_with?('/')
|
24
|
+
tag[:href] = 'https://rubygems.org' + tag[:href]
|
25
|
+
end
|
20
26
|
Display.tags tag
|
21
27
|
end
|
28
|
+
Display.after_result
|
22
29
|
end
|
23
30
|
|
24
31
|
def self.so(keyword)
|
@@ -26,6 +33,9 @@ class SearchProviders
|
|
26
33
|
res = RestClient.get "https://stackoverflow.com/search?q=#{keyword}"
|
27
34
|
tags = Nokogiri::HTML.parse(res).xpath('//a[@class="question-hyperlink"]')
|
28
35
|
tags.each do |tag|
|
36
|
+
if tag[:href].start_with?('/')
|
37
|
+
tag[:href] = 'https://stackoverflow.com' + tag[:href]
|
38
|
+
end
|
29
39
|
Display.tags tag
|
30
40
|
end
|
31
41
|
Display.after_result
|