zoukankan      html  css  js  c++  java
  • EPIC限免提示

    通过云函数每周定时推送限免内容到手机

    import datetime
    import requests
    
    requests.packages.urllib3.disable_warnings()
    
    
    # date = datetime.datetime.strptime(i['effectiveDate'][:-5], "%Y-%m-%dT%H:%M:%S")
    
    
    def get_game():
        dic = {'namespace': [], 'offers': []}
        url = "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=zh-CN&country=CN&allowCountries=CN,JP"
        header = {
            "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Mobile Safari/537.36",
        }
        res = requests.get(url=url, headers=header)
        if res.status_code == 200:
            js = res.json()['data']['Catalog']['searchStore']['elements']
            now = datetime.datetime.now() - datetime.timedelta(days=7)
            for i in js:
                date = datetime.datetime.strptime(i['effectiveDate'][:-5], "%Y-%m-%dT%H:%M:%S")
                if date < now:
                    continue
                else:
                    dic['namespace'].append(i['items'][0]['namespace'])
                    dic['offers'].append(i['id'])
    
                    utc_date = datetime.datetime.strptime(i['effectiveDate'], "%Y-%m-%dT%H:%M:%S.%fZ")
                    local_date = utc_date + datetime.timedelta(days=7)
                    print(
                        '游戏名:' + i['title'] + '
    	游戏描述:' + i['description'] + '
    	游戏厂商:' + i['seller'][
                            'name'] + '
    	开始时间:' +
                        i['effectiveDate'] + '
    	结束时间:' + str(local_date) + '
    	游戏原价:' + i['price']['totalPrice']['fmtPrice'][
                            'originalPrice'], '
    	折后价:' + i['price']['totalPrice']['fmtPrice']['discountPrice'],
                        '
    	namespace:%s 	offers:%s' % (i['items'][0]['namespace'], i['id']))
            return dic
        else:
            print('get请求错误:', res.text)
            return dic
    
    
    if __name__ == '__main__':
        get_game()
  • 相关阅读:
    MooseFS基础和安装
    自动化运维工具SaltStack详细部署
    linux中的通配符与正则表达式
    使用GitHub做个人博客
    mysql数据库分库备份脚本
    php-fpm配置详解
    php-fpm安装、配置与优化
    ceph的正常卸载与非正常卸载
    CentOS系统/tmp目录里面的文件默认保留多久
    ansible常用命令
  • 原文地址:https://www.cnblogs.com/1314h/p/14072956.html
Copyright © 2011-2022 走看看