android_market_api 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/COPYING ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2011
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in android_market_api.gemspec
4
+ gemspec 'hpricot'
5
+ gemspec 'rake-compiler'
data/README ADDED
@@ -0,0 +1,10 @@
1
+ <h2>Android Market Library for parsing Android Market.</h2>
2
+
3
+ This is a unoficial API Managed by Bearstouch Software
4
+
5
+ This project is under development.
6
+
7
+ Fell free to clone it and submit your changes to us.
8
+
9
+ Soon it will be available on Rubygem Website
10
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "android_market_api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "android_market_api"
7
+ s.version = AndroidMarketApi::VERSION
8
+ s.authors = ["Hélder Vasconcelos"]
9
+ s.email = ["heldervasc@bearstouch.com"]
10
+ s.homepage = "http://rubygems.org/gems/android_market_api"
11
+ s.summary = %q{API for parsing Android Market and getting some usefull information about applications}
12
+ s.description = %q{API for parsing Android Market and getting some usefull information about applications}
13
+
14
+ s.rubyforge_project = "android_market_api"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ s.add_dependency "hpricot"
25
+ end
@@ -0,0 +1,61 @@
1
+ # Copyright 2011 by Helder VAsconcelos (heldervasc@bearstouch.com).
2
+ # All rights reserved.
3
+
4
+ # Permission is granted for use, copying, modification, distribution,
5
+ # and distribution of modified versions of this work as long as the
6
+ # above copyright notice is included.
7
+ require 'rubygems'
8
+ require 'hpricot'
9
+ require 'open-uri'
10
+ #require 'android_market_api/android_market_application'
11
+
12
+ class AndroidMarket
13
+
14
+ @@game_categories=Array.[]('ARCADE','BRAIN','CARDS','CASUAL','GAME_WALLPAPER','RACING','SPORTS_GAMES','GAME_WIDGETS')
15
+ @@application_categories=Array.[]('BOOKS_AND_REFERENCE','BUSINESS','COMICS','COMMUNICATION','EDUCATION','ENTERTAINMENT','FINANCE','HEALTH_AND_FITNESS','LIBRARIES_AND_DEMO','LIFESTYLE','APP_WALLPAPER','MEDIA_AND_VIDEO','MEDICAL','MUSIC_AND_AUDIO','NEWS_AND_MAGAZINES','PERSONALIZATION','PHOTOGRAPHY','PRODUCTIVITY','SHOPPING','SOCIAL','SPORTS','TOOLS','TRANSPORTATION','TRAVEL_AND_LOCAL','WEATHER','APP_WIDGETS')
16
+
17
+ #Get Top selling Paids apps for a category
18
+ def AndroidMarket.get_top_selling_paid_apps(category,language='en',start=0)
19
+ apps=Array.new
20
+ url="https://market.android.com/details?id=apps_topselling_paid&cat="+category+"&start="+start.to_s+"&num=24&hl="+language
21
+ puts url
22
+ doc = Hpricot(open(url,'User-Agent' => 'ruby'))
23
+ #i=1
24
+ doc.search("//div[@class='buy-border']//a").each do |buy_div|
25
+ #puts '-------------------------------------------------'
26
+ #puts "| Applicaton Ranking "+i.to_s
27
+ #puts "| Application Name = "+buy_div.attributes['data-doctitle']
28
+ #puts "| Application Package = "+buy_div.attributes['data-docid']
29
+ #puts "| Application Price = "+(buy_div.attributes['data-docpricemicros'].to_i/1000000).to_s
30
+ #puts '-------------------------------------------------'
31
+ puts "Getting Application package "+buy_div.attributes['data-docid']
32
+ app=AndroidMarketApplication.new(buy_div.attributes['data-docid'],language)
33
+ apps.push(app)
34
+ #i=i+1
35
+ end
36
+ return apps
37
+ end
38
+
39
+ #Get Top selling Free apps for a category
40
+ def AndroidMarket.get_top_selling_free_apps(category,language='en',start=0)
41
+ apps=Array.new
42
+ url="https://market.android.com/details?id=apps_topselling_free&cat="+category+"&start="+start.to_s+"&num=24&hl="+language
43
+ doc = Hpricot(open(url,'User-Agent' => 'ruby'))
44
+ #i=1
45
+ doc.search("//div[@class='buy-border']//a").each do |buy_div|
46
+ #puts '-------------------------------------------------'
47
+ #puts "| Applicaton Ranking "+i.to_s
48
+ #puts "| Application Name = "+buy_div.attributes['data-doctitle']
49
+ #puts "| Application Package = "+buy_div.attributes['data-docid']
50
+ #puts "| Application Price = "+(buy_div.attributes['data-docpricemicros'].to_i/1000000).to_s
51
+ #puts '-------------------------------------------------'
52
+ puts "Getting Application package "+buy_div.attributes['data-docid']
53
+ app=AndroidMarketApplication.new(buy_div.attributes['data-docid'],language)
54
+ #i=i+1
55
+ apps.push(app)
56
+ end
57
+ return apps
58
+ end
59
+
60
+ end
61
+
@@ -0,0 +1,222 @@
1
+ # Copyright 2011 by Helder Vasconcelos (heldervasc@bearstouch.com).
2
+ # All rights reserved.
3
+
4
+ # Permission is granted for use, copying, modification, distribution,
5
+ # and distribution of modified versions of this work as long as the
6
+ # above copyright notice is included.
7
+ require 'rubygems'
8
+ require 'open-uri'
9
+ require 'hpricot'
10
+
11
+ class AndroidMarketApplication
12
+
13
+ @@debug=0
14
+ ###########################################################################################
15
+ # Contructor: Example Usage AndroidMarketApplication.new("com.bearstouch.smsscheduler")
16
+ ############################################################################################
17
+ def initialize(package,language='en')
18
+ @package=package
19
+ @language=language;
20
+ @name="" # Application Name
21
+ @current_version="" # Application Current Version
22
+ @price="" # Application Price
23
+ @ratting_value="" # Ratting Value
24
+ @ratting_count="" # Nr of Votes
25
+ @updated="" # Last Upfate datetime
26
+ @sdk_required="" # SDK Required
27
+ @category="" # Category
28
+ @downloads="" # Ratting
29
+ @size="" # Application Size
30
+ @contentRating="" # Content Ratting
31
+ @description="" # Application description
32
+ @screenshots="" # Screenshot URL Array
33
+ @developer_name="" # Developer Name
34
+ @icon="" # Icon URL
35
+ @update_text=""
36
+ @screenshots=Array.new
37
+ @update_text=Array.new
38
+ parseInAndroidMarket(language)
39
+ end
40
+
41
+ ############################################
42
+ # => Parse Default Page for your localization from Android Market
43
+ ############################################
44
+ def parseInAndroidMarket(language)
45
+
46
+ url="https://market.android.com/details?id="+@package+"&hl="+language
47
+ puts "Getting URL="+url if @@debug == 1
48
+ doc = Hpricot(open(url,'User-Agent' => 'ruby'))
49
+ fill_current_version(doc.root)
50
+ fill_ratting_value(doc.root)
51
+ fill_ratting_count(doc.root)
52
+ fill_updated_at(doc.root)
53
+ fill_sdk_required(doc.root)
54
+ fill_category(doc.root)
55
+ fill_downloads(doc.root)
56
+ fill_size(doc.root)
57
+ fill_price(doc.root)
58
+ fill_content_rating(doc.root)
59
+ fill_application_name(doc.root)
60
+ fill_description(doc.root)
61
+ fill_screenshots(doc.root)
62
+ fill_developer_name(doc.root)
63
+ fill_icon(doc.root)
64
+ fill_changed_text(doc.root)
65
+
66
+ end
67
+
68
+ def fill_application_name(doc)
69
+ element=doc.at("dl[@class='doc-metadata-list']/meta[@itemprop='name']")
70
+ if element
71
+ @name=element['content']
72
+ puts "Apllication name ="+@name.to_s if @@debug == 1
73
+ end
74
+ end
75
+
76
+ def fill_current_version(doc)
77
+ element=doc.at("dl[@class='doc-metadata-list']/dd[@itemprop='softwareVersion']")
78
+ if element
79
+ @current_version=element.inner_html
80
+ puts "Apllication Version="+@current_version.to_s if @@debug == 1
81
+ end
82
+ end
83
+
84
+ def fill_price(doc)
85
+ element=doc.at("dl[@class='doc-metadata-list']/dd[@itemprop='offers']/span[@itemprop='price']")
86
+ if element
87
+ @price=element.inner_html
88
+ puts "Apllication Price="+@price.to_s if @@debug == 1
89
+ end
90
+ end
91
+
92
+ def fill_ratting_value(doc)
93
+ element=doc.at("dl[@class='doc-metadata-list']/dd[@itemprop='aggregateRating']/div[@itemprop='ratingValue']")
94
+ if element
95
+ @ratting_value=element['content']
96
+ puts "Apllication Ratting Value ="+@ratting_value.to_s if @@debug == 1
97
+ end
98
+ end
99
+
100
+ def fill_ratting_count(doc)
101
+ element=doc.at("dl[@class='doc-metadata-list']/dd[@itemprop='aggregateRating']/span[@itemprop='ratingCount']")
102
+ if element
103
+ @ratting_count=element.inner_html
104
+ puts "Apllication ratting_count="+@ratting_count.to_s if @@debug == 1
105
+ end
106
+ end
107
+
108
+ def fill_updated_at(doc)
109
+ element=doc.at("dl[@class='doc-metadata-list']/dd/time[@itemprop='datePublished']")
110
+ if element
111
+ @updated=element.inner_html
112
+ puts "Apllication updated="+@updated.to_s if @@debug == 1
113
+ end
114
+ end
115
+
116
+ def fill_sdk_required(doc)
117
+ element=doc.at("dl[@class='doc-metadata-list']/dt[@itemprop='operatingSystems']")
118
+ if element
119
+ @sdk_required=element.next_node.inner_html
120
+ puts "Apllication SDK="+@sdk_required.to_s if @@debug == 1
121
+ end
122
+ end
123
+
124
+ def fill_category(doc)
125
+ #@category=doc.at("dl[@class='doc-metadata-list']/dt[@itemprop='operatingSystems']").next_node.inner_html
126
+ # puts "Apllication category="+@category.to_s if @@debug == 1
127
+ end
128
+
129
+ def fill_downloads(doc)
130
+ element=doc.at("dd[@itemprop='numDownloads']")
131
+ if element
132
+ @downloads=element.children.first
133
+ puts "Apllication install category="+@downloads.to_s if @@debug == 1
134
+ end
135
+ end
136
+
137
+ def fill_size(doc)
138
+ element=doc.at("dl[@class='doc-metadata-list']/dd[@itemprop='fileSize']")
139
+ if element
140
+ @size=element.inner_html
141
+ puts "Apllication Size="+@size.to_s if @@debug == 1
142
+ end
143
+ end
144
+
145
+ def fill_content_rating(doc)
146
+ element=doc.at("dl[@class='doc-metadata-list']/dd[@itemprop='contentRating']")
147
+ if element
148
+ @contentRating=element.inner_html
149
+ puts "Apllication Content Rating="+@contentRating.to_s if @@debug == 1
150
+ end
151
+ end
152
+
153
+ def fill_description(doc)
154
+ element=doc.at("div[@id='doc-original-text']")
155
+ if element
156
+ @description=element.inner_html
157
+ puts "Apllication Description ="+@description.to_s if @@debug == 1
158
+ end
159
+ end
160
+
161
+ def fill_screenshots(doc)
162
+ element_ar=(doc/"div[@class='screenshot-carousel-content-container']/img")
163
+ if element_ar
164
+ element_ar.each do |img|
165
+ puts "addding "+img['src'].to_s if @@debug == 1
166
+ @screenshots.push(img['src'].to_s)
167
+ end
168
+ end
169
+ end
170
+
171
+ def fill_developer_name(doc)
172
+ element=doc.at("a[@class='doc-header-link']")
173
+ if element
174
+ @developer_name=element.inner_html
175
+ puts "Apllication Author= "+@developer_name.to_s if @@debug == 1
176
+ end
177
+ end
178
+
179
+ def fill_icon(doc)
180
+ element=doc.at("div[@class='doc-banner-icon']/img")
181
+ if element
182
+ @icon=element['src']
183
+ puts "Apllication Icon= "+@icon.to_s if @@debug == 1
184
+ end
185
+ end
186
+
187
+ def fill_changed_text(doc)
188
+ element_ar=(doc/"div[@class='doc-whatsnew-container']/ol/li")
189
+ if element_ar
190
+ element_ar.each do |parag|
191
+ puts "Apllication Update= "+parag.inner_html if @@debug == 1
192
+ @update_text << parag.inner_html
193
+ end
194
+ end
195
+ end
196
+
197
+ def to_s()
198
+ puts "-------------------------------------------------------------"
199
+ puts " Application Name = "+@name.to_s
200
+ puts " Application Package = "+@package.to_s
201
+ puts " Application Current Version = "+@current_version.to_s
202
+ puts " Application Price = "+@price.to_s
203
+ puts " Application Ratting Value = "+@ratting_value.to_s
204
+ puts " Application Ratting Count = "+@ratting_count.to_s
205
+ puts " Application Updated = "+@updated.to_s
206
+ puts " SDK required = "+@sdk_required.to_s
207
+ # puts " Category = "+@category.to_s
208
+ puts " Nr of Downloads = "+@downloads.to_s
209
+ puts " Size = "+@size.to_s
210
+ puts " Content Ratting = "+@contentRating.to_s
211
+ puts " Application description = "+@description.to_s
212
+ puts " Developer Name = "+@developer_name.to_s
213
+ puts " Icon URL = "+@icon.to_s
214
+ puts "-------------------------------------------------------------"
215
+ end
216
+
217
+ end
218
+
219
+ puts "Starting ...."
220
+ $app=AndroidMarketApplication.new('com.zeptolab.ctr.paid')
221
+ $app.to_s
222
+ puts "Ending"
@@ -0,0 +1,3 @@
1
+ module AndroidMarketApi
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ # == About android_market_api.rb
2
+ #
3
+ # All of Android Market Api's various part are loaded when you use <tt>require 'android_market_api'</tt>.
4
+ require "android_market_api/android_market_application"
5
+ require "android_market_api/version"
6
+ require "android_market_api/android_market"
data/test.rb ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ ###########################################
3
+ #
4
+ # Android Market Parser
5
+ # Creaated: 12/11/2011
6
+ # Author: Hélder VAsconcelos (heldervasc@bearstouch.com)
7
+ #
8
+ #############################################
9
+ require 'rubygems'
10
+ require 'android_market_api'
11
+
12
+ puts "Starting ...."
13
+ $app=AndroidMarketApplication.new('com.zeptolab.ctr.paid')
14
+ $app.to_s
15
+ puts "Ending"
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: android_market_api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - "H\xC3\xA9lder Vasconcelos"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: hpricot
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: API for parsing Android Market and getting some usefull information about applications
35
+ email:
36
+ - heldervasc@bearstouch.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - .gitignore
45
+ - COPYING
46
+ - Gemfile
47
+ - README
48
+ - Rakefile
49
+ - android_market_api.gemspec
50
+ - lib/android_market_api.rb
51
+ - lib/android_market_api/android_market.rb
52
+ - lib/android_market_api/android_market_application.rb
53
+ - lib/android_market_api/version.rb
54
+ - test.rb
55
+ homepage: http://rubygems.org/gems/android_market_api
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: android_market_api
84
+ rubygems_version: 1.8.11
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: API for parsing Android Market and getting some usefull information about applications
88
+ test_files: []
89
+