今天帮朋友看了一个问题,是post请求使用URL encode对参数进行加密然后进行url拼接,如下图所示:

加密前的参数:

python处理post请求,使用URL encode对参数进行加密

 

 

加密后的参数

python处理post请求,使用URL encode对参数进行加密

 

 

上网查完以后写出解决办法

 

第一步:

# 先对参数进行加密
from urllib.parse import urlencode


a = {"jsonBody":'{"filter":{},"pagination":{"current":2,"pageSize":20},"table":{"sort":{}},"tab":"all"}'}
jsonbody = urlencode(a)

第二步:

对url加密

URL = url + '?' + jsonbody

 

第三步: 请求

# 第一种
import reuqests
rsp = requests.get(url=url,headers=headers)


# 第二种:
from urllib.request import urlopen

request = request.Resquest(url, headers=headers)
rsp = urlopen(request)
print(rsp.read().decode())

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2022-01-01
  • 2021-04-06
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案