import requests
from urllib.parse import urlencode
from jsonpath import jsonpath
import json

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36'
}


url = 'https://web-drcn.hispace.dbankcloud.cn/uowap/index?'
data= ['1', 'C102617855']
#url参数
params = {
    'method': 'internal.getTabDetail',
    'serviceType': '20',
    'reqPageNum': '1',
    'maxResults': '25',
    'uri': 'app%7C' + str(data[1]),
    'shareTo':'',
    'currentUrl': 'https%3A%2F%2Fappstore.huawei.com%2Fapp%2F' + str(data[1]),
    'accessId': '',
    'appid': str(data[1]),
    'zone': '',
    'locale': 'zh' 
}
#拼接url
url_1 = url + urlencode(params) 
print(url_1)

resp = requests.get(url_1)
text = resp.text
print(text)

#转化为json对象
jsonobj = json.loads(text)
print(jsonobj)

#json提取数据
name = jsonpath(jsonobj,'$.name')
print(name[0][5:])
最后修改:2021 年 09 月 26 日
如果觉得我的文章对你有用,请随意赞赏