Python发包为什么自动修改了我的请求参数导致签名失败
本帖最后由 zx2000 于 2020-2-13 19:40 编辑POST https://api.midukanshu.com/user/readTimeBase/readTime
参数:
app=midu&dataEncStr=MEJDMkRDQjk2RDkwNzk5RDUwQzk4MzBDMzNCNEI5MTIuY0dGeVlXMGZNREJsTW1FNU1XWXRNemxqT0MwME1URTNMVGczWVRndFl6UTVaakJoTnpreFpUZzJIblpsY25OcGIyNGZOQjV3YkdGMFptOXliUjloYm1SeWIybGtIbVZqSHpFPS586j4Bf%2FW%2B0YrunJxYIY8VbzCmw%2FegQhtlBxB075LzIRMlpyTohF667Tu%2F3sXQjnvbD2H0QES0ia5fMzhdwyEtzhq6ZKIOE622uPd1bpVvbWRxr5hu%2FCCKdTYeI1GZLp%2FJfFZy%2FRx4p7imf5zSdMJbes9HDPQnsytbt0BI7rvuRV6r3KGVA8tML2wPJmggQAdlLjnGIfusZWzFakK63wXTT%2FL%2BqDvRAw1V3FDyNXzm%2FXmranlItlQk1Yw1cbRlzc4ZJlbS8scCerCO05slpMm83MdVKiAuI3sVlBz8pWEWHjXucufYAJ%2FJN5IWmiOk%2BoTcM6bwJax%2Fnkoj1XXCfJW3ItlNrumEglHxscdycoL%2BdkUAbTs5e6PMssPu9%2B5wlx%2FB6KGwSfX8Ynsog39KyAk8HOt1N6eE%2B%2Bwl6itAI3onGm2WMJqosRxFXgrGHGWDbKO7IicIVDCObndqqRn39LIoNQ0c1fv%2BkLWta2NhAe0N67bE%2FNozt8TCUfnRwjJWt9BfNRKpiS2639wHfslFtcaTFyv7GMyB5%2BxPX9gK8uTHNuNvNnIEZvEKO7XmZJA%2Bo9m7GyDYXBmI9433O5toZbzIzhnZ967j0EqcNuS%2BkMdSw1DiXclzNGQRb02zuTLrdrsQ%2FD%2FicF9tiH3AesfYm3HZ7QcUz%2FwUY9SsrfvRE47%2FFAdKrBtDX6uTwoB5D0nBzxkGXbu1hgsAsK1VmWiXwd%2B4CUSjkEuzcTUi6AzQ9cQ5AE3y2jvabWXkmDgILVEAcWhntEEWEDbpau0BijkvmhGZ79TV%2F%2B05zfo6ol0%2Bhoklt9j1HkgXl4Z4emq9zpte%2BfP%2B2UAE3%2BhQG9zRhAl%2FrT2iAGo%2BN81NZaaRWVv8d84WzEIFcJco7xTSFLnwmn4XXq4Xx4R568RMB43qVQthpB16hvRpTruDDJRnGaq7EbmNKdqm9b2%2BYPlb6yndk5FG3TTxAsN%2FwSM9xBAiTDPp6mZqt%2BiI1oIutv3IUk%2FrHtdZ%2FwNu4NT6PMtVXk1i3YPeW5ImS7PQsqTTwmQvyMzshF0TXyrckLjJSjSyBjAV%2FonKbPr%2F800P8E9W79I4Hh3DaKcJWrJpOZl%2F9IMqqDDL18%2B31dmh3Trc8vAv6tNQcYeW25OVVQ%3D%3D&dtu=xiaomi&version=530&versionName=5.3.0.0117.1827&sign=
这是从fiddler抓到的,通过其他软件发包没有任何问题:
然后我通过python 发送请求发现 返回 签名失败:
{"code":-147,"message":"签名错误","currentTime":1581591642,"data":{}}
通过fiddler发现python 发送的请求中参数已被修改:
Python代码:
import requests;
url="https://api.midukanshu.com/user/readTimeBase/readTime";
header={"User-Agent":"okhttp/3.11.0"}
val={"app":"midu","dataEncStr":"MEJDMkRDQjk2RDkwNzk5RDUwQzk4MzBDMzNCNEI5MTIuY0dGeVlXMGZNREJsTW1FNU1XWXRNemxqT0MwME1URTNMVGczWVRndFl6UTVaakJoTnpreFpUZzJIblpsY25OcGIyNGZOQjV3YkdGMFptOXliUjloYm1SeWIybGtIbVZqSHpFPS586j4Bf%2FW%2B0YrunJxYIY8VbzCmw%2FegQhtlBxB075LzIRMlpyTohF667Tu%2F3sXQjnvbD2H0QES0ia5fMzhdwyEtzhq6ZKIOE622uPd1bpVvbWRxr5hu%2FCCKdTYeI1GZLp%2FJfFZy%2FRx4p7imf5zSdMJbes9HDPQnsytbt0BI7rvuRV6r3KGVA8tML2wPJmggQAdlLjnGIfusZWzFakK63wXTT%2FL%2BqDvRAw1V3FDyNXzm%2FXmranlItlQk1Yw1cbRlzc4ZJlbS8scCerCO05slpMm83MdVKiAuI3sVlBz8pWEWHjXucufYAJ%2FJN5IWmiOk%2BoTcM6bwJax%2Fnkoj1XXCfJW3ItlNrumEglHxscdycoL%2BdkUAbTs5e6PMssPu9%2B5wlx%2FB6KGwSfX8Ynsog39KyAk8HOt1N6eE%2B%2Bwl6itAI3onGm2WMJqosRxFXgrGHGWDbKO7IicIVDCObndqqRn39LIoNQ0c1fv%2BkLWta2NhAe0N67bE%2FNozt8TCUfnRwjJWt9BfNRKpiS2639wHfslFtcaTFyv7GMyB5%2BxPX9gK8uTHNuNvNnIEZvEKO7XmZJA%2Bo9m7GyDYXBmI9433O5toZbzIzhnZ967j0EqcNuS%2BkMdSw1DiXclzNGQRb02zuTLrdrsQ%2FD%2FicF9tiH3AesfYm3HZ7QcUz%2FwUY9SsrfvRE47%2FFAdKrBtDX6uTwoB5D0nBzxkGXbu1hgsAsK1VmWiXwd%2B4CUSjkEuzcTUi6AzQ9cQ5AE3y2jvabWXkmDgILVEAcWhntEEWEDbpau0BijkvmhGZ79TV%2F%2B05zfo6ol0%2Bhoklt9j1HkgXl4Z4emq9zpte%2BfP%2B2UAE3%2BhQG9zRhAl%2FrT2iAGo%2BN81NZaaRWVv8d84WzEIFcJco7xTSFLnwmn4XXq4Xx4R568RMB43qVQthpB16hvRpTruDDJRnGaq7EbmNKdqm9b2%2BYPlb6yndk5FG3TTxAsN%2FwSM9xBAiTDPp6mZqt%2BiI1oIutv3IUk%2FrHtdZ%2FwNu4NT6PMtVXk1i3YPeW5ImS7PQsqTTwmQvyMzshF0TXyrckLjJSjSyBjAV%2FonKbPr%2F800P8E9W79I4Hh3DaKcJWrJpOZl%2F9IMqqDDL18%2B31dmh3Trc8vAv6tNQcYeW25OVVQ%3D%3D","dtu":"xiaomi","version":"530","versionName":"5.3.0.0117.1827","sign":""};
result=requests.post(url,val,headers=header);
print(result.content.decode())
希望哪位大神能够帮我找出问题!不胜感激! 本帖最后由 wuzonghui 于 2020-2-13 19:30 编辑
requests发包会自动url编码,你需要把%2F改回/
```
import requests;
url="https://api.midukanshu.com/user/readTimeBase/readTime";
header={"User-Agent":"okhttp/3.11.0"}
val={"app":"midu","dataEncStr":"MEJDMkRDQjk2RDkwNzk5RDUwQzk4MzBDMzNCNEI5MTIuY0dGeVlXMGZNREJsTW1FNU1XWXRNemxqT0MwME1URTNMVGczWVRndFl6UTVaakJoTnpreFpUZzJIblpsY25OcGIyNGZOQjV3YkdGMFptOXliUjloYm1SeWIybGtIbVZqSHpFPS586j4Bf/W+0YrunJxYIY8VbzCmw/egQhtlBxB075LzIRMlpyTohF667Tu/3sXQjnvbD2H0QES0ia5fMzhdwyEtzhq6ZKIOE622uPd1bpVvbWRxr5hu/CCKdTYeI1GZLp/JfFZy/Rx4p7imf5zSdMJbes9HDPQnsytbt0BI7rvuRV6r3KGVA8tML2wPJmggQAdlLjnGIfusZWzFakK63wXTT/L+qDvRAw1V3FDyNXzm/XmranlItlQk1Yw1cbRlzc4ZJlbS8scCerCO05slpMm83MdVKiAuI3sVlBz8pWEWHjXucufYAJ/JN5IWmiOk+oTcM6bwJax/nkoj1XXCfJW3ItlNrumEglHxscdycoL+dkUAbTs5e6PMssPu9+5wlx/B6KGwSfX8Ynsog39KyAk8HOt1N6eE++wl6itAI3onGm2WMJqosRxFXgrGHGWDbKO7IicIVDCObndqqRn39LIoNQ0c1fv+kLWta2NhAe0N67bE/Nozt8TCUfnRwjJWt9BfNRKpiS2639wHfslFtcaTFyv7GMyB5+xPX9gK8uTHNuNvNnIEZvEKO7XmZJA+o9m7GyDYXBmI9433O5toZbzIzhnZ967j0EqcNuS+kMdSw1DiXclzNGQRb02zuTLrdrsQ/D/icF9tiH3AesfYm3HZ7QcUz/wUY9SsrfvRE47/FAdKrBtDX6uTwoB5D0nBzxkGXbu1hgsAsK1VmWiXwd+4CUSjkEuzcTUi6AzQ9cQ5AE3y2jvabWXkmDgILVEAcWhntEEWEDbpau0BijkvmhGZ79TV/+05zfo6ol0+hoklt9j1HkgXl4Z4emq9zpte+fP+2UAE3+hQG9zRhAl/rT2iAGo+N81NZaaRWVv8d84WzEIFcJco7xTSFLnwmn4XXq4Xx4R568RMB43qVQthpB16hvRpTruDDJRnGaq7EbmNKdqm9b2+YPlb6yndk5FG3TTxAsN/wSM9xBAiTDPp6mZqt+iI1oIutv3IUk/rHtdZ/wNu4NT6PMtVXk1i3YPeW5ImS7PQsqTTwmQvyMzshF0TXyrckLjJSjSyBjAV/onKbPr/800P8E9W79I4Hh3DaKcJWrJpOZl/9IMqqDDL18+31dmh3Trc8vAv6tNQcYeW25OVVQ==","dtu":"xiaomi","version":"530","versionName":"5.3.0.0117.1827","sign":""};
result=requests.post(url,val,headers=header);
print(result.content.decode())
```
试试 不是post(url,data = val,headers = headers)这样吗,原来可以省略啊 你框出来的时候就应该知道是因为编码的问题,你应该直接把这个被编码的原始url解码之后再拿来用的 jidesheng6 发表于 2020-2-13 19:39
你框出来的时候就应该知道是因为编码的问题,你应该直接把这个被编码的原始url解码之后再拿来用的
对URL编码不太熟悉.... zx2000 发表于 2020-2-13 19:41
对URL编码不太熟悉....
反正,这一类先解码了再来用,不然它里面又会编码一次
页:
[1]