import requests import sys import random api = { 'number':[ 'https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%7B"itemNumId"%3A"%s"%7D&qq-pf-to=pcqq.group&name="zhgangsan"', 'https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%7B"itemNumId"%3A"%s"%7D&qq-pf-to=pcqq.group&name="lisi"', 'https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%7B"itemNumId"%3A"%s"%7D&qq-pf-to=pcqq.group&name="wangwu"', ], 'keyword':{ }, } data = { "data":{"itemNumId":"10031645140"}, "qq-pf-to":"pcqq.group", } headers = {'content-type': 'application/json'} strNumId = input( '请输入淘宝读取编号:' ) type = 'number' apis = len( api.get( type ) ) item = random.randint( 0, apis ) url = api.get( type ).pop( item ).replace( "%s", strNumId ) req = requests.get( url, headers ) reqJson = req.json() #itemInfo = reqJson.get( 'data' ).get( 'item' ) #print( itemInfo ) shopInfo = reqJson.get( 'data' ).get( 'seller' ) print( shopInfo )