Open llipeng opened 5 years ago
收集URL respon=request(url) if httpcode ?200 print respon.getjosn 解析json,取shareurl sharerespons=request(shareurl) shareres httpcode 200 esle: 解析Url,getjiakeID if getJiakeID=?: print else: print(获取。。。) print(getUserinfo(a))
#!/usr/lib/env python3 #Author:lipeng import requests from urllib.parse import urlparse,parse_qs def getJsonValue(josnObject,key): if key in josnObject: # print(josnObject[key]) return josnObject[key] else: for i in josnObject: if type(josnObject[i])==dict or type(josnObject[i])==list: return getJsonValue(josnObject[i],key) response = requests.get('testurl') print(response.status_code) # print(response.json()) js = response.json() print(getJsonValue(js,'weixin')['shareURL']) shareUrl=getJsonValue(js,'weixin')['shareURL'] response2 = requests.get(shareUrl) print(response2.status_code) if response2.status_code == 200: print('分享接口可以请求成功') else: print('接口请求失败') urlstr = response2.url print(urlparse(urlstr).query) jiakeId = parse_qs(urlparse(urlstr).query).get('jiakeId') # print(response.headers) if jiakeId : print("jiakeid:",jiakeId) else: print("jiakeId为空")
伪代码
代码实现