chrome_store_search 0.0.6 → 0.0.7
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/chrome_store_search/app.rb +1 -1
- data/lib/chrome_store_search/search.rb +4 -15
- data/lib/chrome_store_search/string_utility.rb +15 -0
- 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: 9a7308dd2be4ba22354cdb6b0da9c42f6950bd1e
|
4
|
+
data.tar.gz: 1866bf6e5acfbb179017b569565c8c3cf3429153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a873280fe46559a93421ffe5bbbad072af44c1e4ee42681e7f301208e9fc0c076ad4cc85c2ae41d29deeea63d606869bdb992a5fd5457210a4cb710d255f1cd
|
7
|
+
data.tar.gz: d7f06752de98f53213846756bbda647ebbf4188a8815a885bed6ba14cb3d17fb878799211bce249b1360328b8f839747129e2493d34790935901f4d3013bf691
|
@@ -44,7 +44,7 @@ module ChromeStoreSearch
|
|
44
44
|
def init_detail_url(id)
|
45
45
|
detail_url = APP_DETAIL_BASE_URL
|
46
46
|
detail_url << "hl=#{@parmeter[:hl]}"
|
47
|
-
detail_url << "&pv
|
47
|
+
detail_url << "&pv=#{StringUtility.get_pv}"
|
48
48
|
detail_url << "&id=#{id}"
|
49
49
|
detail_url << "&container=CHROME"
|
50
50
|
end
|
@@ -2,13 +2,12 @@ require 'rubygems'
|
|
2
2
|
require 'cgi'
|
3
3
|
require 'faraday'
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/app_parser')
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/string_utility')
|
5
6
|
|
6
7
|
module ChromeStoreSearch
|
7
8
|
class Search
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
CHROME_STORE_SEARCH_URL = CHROME_STORE_URL + "ajax/item?"
|
10
|
+
CHROME_STORE_SEARCH_URL = "https://chrome.google.com/webstore/ajax/item?"
|
12
11
|
|
13
12
|
DEFAULT_SEARCH_CONDITION = {:hl =>"en-US",
|
14
13
|
:count => 20,
|
@@ -35,20 +34,10 @@ module ChromeStoreSearch
|
|
35
34
|
query_url << CHROME_STORE_SEARCH_URL
|
36
35
|
query_url << "hl=#{@search_condition[:hl]}"
|
37
36
|
query_url << "&count=#{@search_condition[:count]}"
|
38
|
-
query_url << "&pv=#{get_pv}"
|
37
|
+
query_url << "&pv=#{StringUtility.get_pv}"
|
39
38
|
query_url << "&container=CHROME&sortBy=0"
|
40
39
|
query_url << "&category=#{@search_condition[:category]}" if @search_condition[:category]
|
41
40
|
query_url << "&searchTerm=#{CGI.escape(@keyword)}"
|
42
41
|
end
|
43
|
-
|
44
|
-
def get_pv
|
45
|
-
conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
|
46
|
-
faraday.request :url_encoded # form-encode POST params
|
47
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
48
|
-
end
|
49
|
-
res = conn.get ''
|
50
|
-
res.body.match(/\/webstore\/static\/(\d+)\/wall/)[1]
|
51
|
-
end
|
52
|
-
|
53
42
|
end
|
54
|
-
end
|
43
|
+
end
|
@@ -1,5 +1,10 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
1
3
|
module ChromeStoreSearch
|
2
4
|
class StringUtility
|
5
|
+
|
6
|
+
CHROME_STORE_URL = "https://chrome.google.com/webstore/"
|
7
|
+
|
3
8
|
def self.gsub_continuation_commas(json_str)
|
4
9
|
json_str.gsub(/,,,*/) do |commas_str|
|
5
10
|
replace_str = ""
|
@@ -9,5 +14,15 @@ module ChromeStoreSearch
|
|
9
14
|
commas_str = replace_str + ","
|
10
15
|
end
|
11
16
|
end
|
17
|
+
|
18
|
+
|
19
|
+
def self.get_pv
|
20
|
+
conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
|
21
|
+
faraday.request :url_encoded # form-encode POST params
|
22
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
23
|
+
end
|
24
|
+
res = conn.get ''
|
25
|
+
res.body.match(/\/webstore\/static\/(\d+)\/wall/)[1]
|
26
|
+
end
|
12
27
|
end
|
13
28
|
end
|