diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index ebbf49e..5c27542 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -225,12 +225,16 @@ def bjnews_channel(category=''): from rsshub.spiders.bjnews.channel import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) +@bp.route('/appstore/top//') +def appstore_top(cc='', genreid=''): + from rsshub.spiders.appstore.top import ctx + return render_template('main/atom.xml', **filter_content(ctx(cc,genreid))) + @bp.route('/filter/') def rss_filter(): from rsshub.spiders.rssfilter.filter import ctx feed_url = request.args.get("feed") return render_template('main/atom.xml', **filter_content(ctx(feed_url))) - ''' @bp.route('/test') @bp.route('/test/测试') diff --git a/rsshub/spiders/appstore/top.py b/rsshub/spiders/appstore/top.py new file mode 100644 index 0000000..9ffef73 --- /dev/null +++ b/rsshub/spiders/appstore/top.py @@ -0,0 +1,64 @@ +import json +import requests + +domain = 'https://itunes.apple.com' + +countries = {"CN": "143465-19", +"US": "143441-1", +"JP": "143462-9", +"KR": "143466-13", +"HK": "143463-18", +"AU": "143460", +"TW": "143470-18", +"CA": "143455-6", +"DK": "143458-2", +"RU": "143469-16", +"ID": "143476-2", +"TR": "143480-2", +"GR": "143448-2", +"DE": "143443-4", +"IT": "143450-7", +"NO": "143457-2", +"FR": "143442-3", +"TH": "143475-2", +"SE": "143456-17", +"FI": "143447-2", +"GB": "143444", +"NL": "143452-10", +"BR": "143503-15", +"PT": "143453-24", +"MX": "143468-28", +"ES": "143454-8", +"VN": "143471-2"} + +def gen_headers(cc=''): + headers = { + "Accept-Language": f"{cc}", + "User-Agent": "AppStore/2.0 iOS/10.2 model/iPhone6,1 hwp/s5l8960x build/14C92 (6; dt:89)", + 'Accept': '*/*' , + 'X-Apple-Store-Front': f'{countries[cc.upper()]},29' , + } + return headers + +def parse(post): + item = {} + subtitle = post['name'] + ': ' + post['subtitle'] if post.__contains__('subtitle') else post['name'] + item['title'] = post['name'] + item['description'] = subtitle + '

开发者: ' + '' + post['artistName'] + ' ' \ + + '

Rating: ' + str( post['userRating']['value'] ) \ + + ',数量:' + str( post['userRating']['ratingCount'] ) + item['link'] = post['shortUrl'] + return item + +def ctx(cc='', genreid=''): + top_url = f"{domain}/WebObjects/MZStore.woa/wa/viewTop?cc={cc}&genreId={genreid}&l=en" + res = requests.get(top_url, headers=gen_headers(cc)).json() + posts = res['storePlatformData']['lockup']['results'].values() + + return { + 'title': f'Top Apps in {cc} - App Store', + 'link': top_url, + 'description': f'Top Apps in {cc} - App Store', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } \ No newline at end of file diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index d39f63d..a46962a 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -42,6 +42,19 @@
+ +
+
+

Top App - App Store

+
Top App by hillerliao
+

举例:https://pyrsshub.vercel.app/appstore/top/us/36

+

路由:/appstore/top/:countrycode/:genreid

+

参数:countrycode,国家/地区代码, 如 us、cn、ru、br;genreid,类别,如 36, 6000,6014,6026,更多详见 https://t.ly/vYJI

+
+
+
+ +

传送门-失效