| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486 |
- import inspect
- import utils
- from loguru import logger
- def get_stock_list():
- '''
- 闪购
- :return:
- '''
- url = "https://api.qiandao.com/c2c-web/v1/stock-order/bargin-v3"
- data = {
- "tagIds": [
- 1422849,
- 1132249,
- 1275579,
- 1622975,
- 1583218,
- 1706130,
- 1113003,
- 1000375,
- 1572324,
- 1436291,
- 1560387,
- 1276355,
- 1423075,
- 1583179,
- 42474,
- 324,
- 1446179,
- 1533642,
- 1542944,
- 1568717,
- 1572231,
- 1532176,
- 1506156,
- 1568683,
- 1541805,
- 1277151,
- 1529427,
- 1514792,
- 1515959,
- 1541749
- ],
- "withStockCount": 4
- }
- return utils.reuqest_post_data(url, data)
- def get_stock_tag_list(tag_id, sort):
- '''
- 闪购-按卡牌ID搜索
- :param tag_id: 卡片名称,比如:小马宝莉
- :param sort: 排序类型,0-最多人买,1-最低价格,2-最多在售,7-最新降价
- :return:
- '''
- url = "https://api.qiandao.com/stock-order/bargin"
- data = {
- "tagIds": [
- tag_id
- ],
- "sort": sort,
- "offset": 0,
- "limit": 10
- }
- return utils.reuqest_post_data(url, data)
- def get_spu_trading(spu_id):
- '''
- SPU一年成交
- :param spu_id:
- :return:
- '''
- url = "https://api.qiandao.com/c2c-web/v1/common/get-spu-trading-summary-by-time"
- data = {
- "spuId": spu_id,
- "tradingType": "EXCHANGE",
- "timeBucketWidth": "365 days"
- }
- return utils.reuqest_post_data(url, data)
- def get_spu_trading_history_list(spu_id, page):
- '''
- 分页采集SPU历史成交
- :param spu_id:
- :param page:
- :return:
- '''
- url = "https://api.qiandao.com/c2c-web/v1/common/get-spu-trading-history-list"
- limit = 20
- offset = (page - 1) * limit
- data = {
- "spuId": spu_id,
- "skuId": "0",
- "tradingType": "EXCHANGE",
- "limit": limit,
- "offset": offset
- }
- resp = utils.reuqest_post_data(url, data)
- return resp['data']
- def get_auctions_list(offest):
- url = "https://api.qiandao.com/c2c-web/v1/auctioneer/auctions/by-tags"
- data = {
- "tagIds": [
- "1405184",
- "1132249",
- "1000375",
- "49695",
- "1002041",
- "1540933",
- "1439689"
- ],
- "limit": 10,
- # "offset": 0,
- "offset": offest,
- "sort": "NewestBidTime"
- }
- return utils.request_post_data(logger, url, data)
- def get_auction_list_all_page():
- offest = 0
- while True:
- resp = get_auctions_list(offest)
- if not resp:
- break
- offest += 10
- logger.info(f'分页采集,{offest}:{resp}')
- def get_luckybag_list(offest):
- url = "https://api.qiandao.com/c2c-web/v1/luckybag/list"
- params = {
- "limit": "10",
- # "offset": "0",
- "offset": offest,
- "hostId": "228946998408215136",
- "orderBy": "updatedAt.desc",
- "tagIds": "1429578",
- "typeIds": "1405184,1132249,1000375,49695,1443553,1002041"
- }
- return utils.reuqest_get_data(url, params)
- def get_luckybag_list_all_page():
- offest = 0
- while True:
- resp = get_luckybag_list(offest)
- if not resp:
- break
- logger.info(f'分页采集,{offest}:{resp}')
- offest += 10
- def get_recommender_list():
- url = "https://api.qiandao.com/shelf-web/list-home-recommender"
- params = {
- "offset": 0,
- # "offset": offset,
- "limit": 20,
- "cmd": "b2c_homepage_feed",
- "name": "",
- "project": "",
- "recommendTagIds": [
- 49695,
- 1572285,
- 1542944,
- 1541805,
- 1515843,
- 1436291,
- 1422849,
- 1398583,
- 1132249,
- 1000375
- ],
- "fixedShelfId": 676864889976963108,
- "withLive": "true"
- }
- return utils.request_get_data(logger, url, params)
- def get_recommender_list_all_page():
- offset = 0
- while True:
- resp = get_recommender_list(offset)
- if not resp:
- break
- logger.info(f'分页采集,{offset}:{resp}')
- offset += 20
- def cw_list():
- url = 'https://api.qiandao.com/shelf-web/list-home-recommender'
- params = {
- 'offset': 0,
- 'limit': 20,
- 'cmd': 'b2c_homepage_feed',
- 'name': '',
- 'project': '',
- 'recommendTagIds': [
- 307, 682, 302, 305, 1163995, 50124, 303, 1153225, 525, 57703,
- 1285426, 313, 671, 589, 590, 10210, 1206, 1387773, 1424125,
- 1270645, 1285466, 42474
- ],
- 'fixedShelfId': 568851822601738191,
- 'withLive': 'true'
- }
- # params1 = {
- # 'offset': 0,
- # 'limit': 20,
- # 'cmd': 'b2c_homepage_feed',
- # 'name': '',
- # 'project': '',
- # "recommendTagIds": [
- # 15,1443323],
- # 'fixedShelfId': 568851822601738191,
- # 'withLive': 'true'
- # }
- # url = "https://api.qiandao.com/shelf-web/list-home-recommender"
- # params = {
- # "limit": '10',
- # "offset": '0',
- # "cmd": "b2c_homepage_feed",
- # "project": "channel",
- # "name": "manghe",
- # "type[]": [
- # "BLIND_BOX_MACHINE",
- # "KUJI",
- # "NEW_LUCKY_BAG",
- # "B2C"
- # ],
- # "typeIds": [15],
- # "channelId": '397228442736842784',
- # "screenName": "推荐"
- # }
- # # url = 'https://api.qiandao.com/shelf-web/list-home-recommender?limit=10&offset=0&cmd=b2c_homepage_feed&project=channel&name=manghe&type%5B%5D=BLIND_BOX_MACHINE&type%5B%5D=KUJI&type%5B%5D=NEW_LUCKY_BAG&type%5B%5D=B2C&typeIds%5B%5D=15&channelId=397228442736842784&screenName=%E6%8E%A8%E8%8D%90'
- # params = {
- # 'limit': '10',
- # 'offset': '0',
- # 'cmd': 'b2c_homepage_feed',
- # 'project': 'channel',
- # 'name': 'manghe',
- # 'type[]': ['BLIND_BOX_MACHINE', 'KUJI', 'NEW_LUCKY_BAG', 'B2C'],
- # 'typeIds[]': [15],
- # 'channelId': 397228442736842784,
- # 'screenName': '推荐'
- # }
- # url = "https://api.qiandao.com/shelf-web/list-home-recommender"
- # params = {
- # "offset": "40",
- # "limit": "20",
- # "cmd": "b2c_homepage_feed",
- # "name": "manghe",
- # "project": "channel",
- # "type": [
- # "BLIND_BOX_MACHINE",
- # "KUJI",
- # "NEW_LUCKY_BAG",
- # "B2C"
- # ],
- # "withLive": "true"
- # }
- return utils.request_get_data(logger, url, params)
- def zuzui111():
- url = "https://api.qiandao.com/box/live-groupon/group"
- params = {
- "shelfId": "866155019739620861"
- }
- response = utils.request_get_data(logger, url, params)
- print(response)
- def ttt():
- url = "https://api.qiandao.com/shelf-web/list-home-recommender"
- params = {
- "offset": "0",
- # "offset": str((page - 1) * 20),
- "limit": "20",
- "cmd": "b2c_homepage_feed",
- "name": "cgmarket",
- "project": "channel",
- # "type": "LIVE_GROUPON",
- "type": "",
- "typeIds": [1443323],
- "withLive": "true",
- "tagIds": [1572283],
- "quickCouponTemplateId": "0"
- }
- # cookies = {
- # "acw_tc": "0bca30fa17504130952641968e04896b05764741c46f0da6fec6561158ee4f"
- # }
- resp_json = utils.request_get_data(logger, url, params)
- print(resp_json)
- def rourou(log, page):
- url = "https://api.qiandao.com/c2c-web/v1/common/get-spu-trading-history-list"
- data = {
- "spuId": "654833013418492066",
- # "spuId": spu_id,
- "skuId": "0",
- # "tradingType": "EXCHANGE",
- "tradingType": "",
- "limit": "20",
- "offset": f"{(page - 1) * 20}"
- }
- resp_json = utils.request_post_data(log, url, data)
- print(resp_json)
- def paimai(log, page):
- url = "https://api.qiandao.com/c2c-web/v1/auctioneer/auctions/by-tags"
- data = {
- "tagIds": [
- "1405184",
- "1132249",
- "1000375",
- "49695",
- "1002041",
- "1540933",
- "1439689"
- ],
- "limit": "10",
- "offset": (page - 1) * 10,
- "filterOfficialCertification": False,
- "sort": "End"
- }
- resp_json = utils.request_post_data(log, url, data)
- print(resp_json)
- def kbs_detail_test(log, pid, sql_pool):
- url = "https://api.qiandao.com/box/kuji/query/detail"
- params = {
- # "id": "873770249084734603"
- "id": "774626078722365753"
- # "id": pid
- }
- resp_json = utils.request_get_data(log, url, params)
- print(resp_json)
- if resp_json.get("code") == 0:
- parse_card_bag_reward_details_data(log, resp_json, pid, sql_pool)
- else:
- log.error(f"{inspect.currentframe().f_code.co_name} error: {resp_json.get('message')}")
- def parse_card_bag_reward_details_data(log, resp_json, pid, sql_pool):
- log.debug(f"--------------- {inspect.currentframe().f_code.co_name} ---------------")
- data = resp_json.get("data")
- specification = data.get("packageConfigRamark") # 规格说明
- introImages = data.get('images', {}).get("introImages", [])
- introImages = '|'.join(introImages) # 多图链接, |分割
- # categoryId = data.get("categoryId")
- vipPrice = data.get("vipPrice")
- unitPriceOfCash = data.get("unitPriceOfCash")
- detail_dict = {
- # "pid": pid,
- "specification": specification,
- "images": introImages,
- # "category_id": categoryId,
- "unit_price_of_cash": unitPriceOfCash,
- "vip_price": vipPrice,
- }
- print(detail_dict)
- def kbs_list(log, sql_pool):
- url = "https://api.qiandao.com/shelf-web/list-home-recommender"
- params = {
- "offset": "0",
- # "offset": str((page - 1) * 20),
- "limit": "20",
- "cmd": "b2c_homepage_feed",
- "name": "cgmarket",
- "project": "channel",
- "type": "LIVE_GROUPON",
- "typeIds": [1443323],
- "withLive": "true",
- "tagIds": [1701791],
- "quickCouponTemplateId": "0"
- }
- resp_json = utils.request_get_data(log, url, params)
- print(resp_json)
- rows = resp_json["data"]["rows"]
- sql_pid_list = []
- parse_card_bag_reward_data(log, rows, sql_pool, sql_pid_list)
- def parse_card_bag_reward_data(log, resp_json, sql_pool, sql_pid_list):
- log.debug(f"--------------- {inspect.currentframe().f_code.co_name} ---------------")
- info_list = []
- for item in resp_json:
- # print(item)
- pid = item.get("id")
- if pid in sql_pid_list:
- log.debug(f"{inspect.currentframe().f_code.co_name}, pid: {pid} already exists")
- continue
- p_type = item.get("type")
- orgId = item.get("orgId")
- title = item.get("name")
- # description = item.get("description")
- isSoldOut = item.get("isSoldOut")
- price = item.get("price", {}).get("unitPriceOfCash")
- soldAmountText = item.get("soldAmountText")
- nickname = item.get("org", {}).get("nickname", '')
- info_dict = {
- "pid": pid,
- "p_type": p_type,
- "title": title,
- "price": price,
- "sold_amount_text": soldAmountText,
- "org_id": orgId,
- "nickname": nickname,
- # "description": description,
- "is_sold_out": isSoldOut
- }
- print(info_dict)
- def kbs_buy(log, pid):
- url = "https://api.qiandao.cn/b2c-web/v1/kuji/query/group/next"
- params = {
- # "shelfId": "776833910955877820"
- "shelfId": pid
- }
- token = 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijg2NTIxNTgzOTI0MDk4MzQ1NyIsInR5cGUiOiJVU0VSIiwiZGV2aWNlSWQiOiIxMDA2IiwiZXhwIjoxNzU3MjE0MDYwLCJpYXQiOjE3NTY5NTQ4NjB9.zhQ_mM74Q5apewGXoMXpGRR2O2bjVExSFOjj7gJzf59yM10pE02pOCqClj3H5YQu6t3UHTXdoiuWlumkpyFy3e7ujtdJFv2IBg25XIx24Eklxm6xWsTM7cTzNlq3QrB78IP74pRhu-XDNu3tCdukhjls5Uipe3_hrtPt9LZJUt48agIfAnApiIpGqsXD9V302Lr8fuigVclH-3DMh0YZElKyLrAV0PCWS65nr4INwKljQPtKj83co6N0Q3K_ntg8h5F68OIJf9Tgcome9LuT2_jvJ75n7Qnnr4AZiv9rQuum51ygeZtYiINPghd7zbEbL5L-oATB3xhT_MqR0NVWQg'
- resp_json = utils.request_get_data(log, url, params, token)
- # resp_json = utils.request_get_data(log, url, params)
- print(resp_json)
- # ----------------------------------------------------------------------------------------------------------------------
- # 潮玩
- def tttt(log, page_num, tag_id):
- url = "https://api.qiandao.cn/stock-order/bargin"
- data = {
- # "tagId": "682",
- "tagId": int(tag_id),
- "limit": 10,
- "offset": (page_num - 1) * 10,
- # "isWished": False,
- "sort": 0 # 最多人买
- }
- data = {
- "tagIds": [
- int(tag_id)
- ],
- "sort": 0, # 最多人买
- "offset": (page_num - 1) * 10,
- "limit": 10
- }
- resp_json = utils.request_post_data(log, url, data)
- print(resp_json)
- if __name__ == '__main__':
- kbs_buy(logger, '885836131847950829')
- # kbs_detail_test(logger, '11111', None)
- # kbs_list(logger, None)
- # ttt()
- # cw_list()
- # logger.info(f'闪购:{get_recommender_list()}')
- # logger.info(f'闪购:{cw_list()}')
- # page = 500
- # for i in range(1, page):
- # ttt(logger, i, 682)
|