get请求的utl数据是这样的,例如:/banner/findBanner?bannerType=1&_=1556107073181
‘‘‘ 1-banner图-banner/findBanner ‘‘‘ str1=parse.urlencode(data1) url1=‘{0}/banner/findBanner?bannerType=1&_=1556107073181‘.format(yuming) headers ={‘Content-Type‘:‘application/json;charset=UTF-8‘, ‘Accept‘:‘application/json, text/javascript, */*; q=0.01‘, ‘Referer‘:‘{0}/‘.format(yuming)} r=requests.get(url=url1,headers=headers) repones=r.text print(‘*‘*100,‘\n‘,‘1-banner图-banner/findBanner‘,‘\n‘,‘*‘*100) print() print(r.status_code) print(r.text)
如果参数比较多的话如何自动拼接呢
from urllib import parse ‘‘‘ 1-banner图-banner/findBanner ‘‘‘ data1={ ‘bannerType‘:1, ‘_‘:1556107073181 } str1=parse.urlencode(data1) url1=‘{0}/banner/findBanner?{1}‘.format(yuming,str1) headers ={‘Content-Type‘:‘application/json;charset=UTF-8‘, ‘Accept‘:‘application/json, text/javascript, */*; q=0.01‘, ‘Referer‘:‘{0}/‘.format(yuming)} r=requests.get(url=url1,headers=headers) repones=r.text print(‘*‘*100,‘\n‘,‘1-banner图-banner/findBanner‘,‘\n‘,‘*‘*100) print() print(r.status_code) print(r.text)
原文地址:https://www.cnblogs.com/jpr-ok/p/10819132.html
时间: 2024-11-29 07:37:56