From e4df58cb5f8baef5ade3736794fc37df17044e31 Mon Sep 17 00:00:00 2001 From: FroyoRab <49470951+FroyoRab@users.noreply.github.com> Date: Fri, 25 Sep 2020 14:44:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E8=AE=AE=20http=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=BD=A2=E5=8F=82=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E5=86=B3=E5=AE=9A=E6=98=AF=E5=90=A6=E5=AF=B9?= =?UTF-8?q?post=E6=83=85=E5=86=B5=E4=B8=8B=E7=9A=84=20httpBody=20=20?= =?UTF-8?q?=E8=BF=9B=E8=A1=8Curl=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 有时候测试的时候还是希望可控一些,我写的是utf-8编码的,但是好像看到代码里有用ascii编码的? 另外可能跟httpraw的功能有一些些重,介于这些所以上次没提,但是方便啊!hh --- HackRequests/HackRequests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HackRequests/HackRequests.py b/HackRequests/HackRequests.py index 8706098..0964618 100644 --- a/HackRequests/HackRequests.py +++ b/HackRequests/HackRequests.py @@ -260,6 +260,7 @@ def http(self, url, **kwargs): post = kwargs.get("post", None) or kwargs.get("data", None) location = kwargs.get('location', True) locationcount = kwargs.get("locationcount", 0) + dataNeedUrlEncode = kwargs.get('dataEncode',True) proxy = kwargs.get('proxy', None) headers = kwargs.get('headers', {}) @@ -302,7 +303,9 @@ def http(self, url, **kwargs): except: pass try: - post = parse.urlencode(post) + if dataNeedUrlEncode: + post = parse.urlencode(post) + else: post = post.encode('utf-8') except: pass if "Content-Type" not in headers: