From 0e58e0c0798f0ac5c95e4b9683d2482ef169010b Mon Sep 17 00:00:00 2001 From: ngfchl Date: Sat, 24 Sep 2022 10:28:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0U2=E9=9A=8F=E6=9C=BA=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BD=8E=E4=BF=9D=E6=94=B6?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pt_site/UtilityTool.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pt_site/UtilityTool.py b/pt_site/UtilityTool.py index a888779..9d93eaa 100644 --- a/pt_site/UtilityTool.py +++ b/pt_site/UtilityTool.py @@ -162,6 +162,7 @@ class PtSpider: method: str = 'get', data: dict = None, params: dict = None, + json: dict = None, timeout: int = 20, delay: int = 15, headers: dict = {}, @@ -180,6 +181,7 @@ class PtSpider: cookies=self.cookies2dict(my_site.cookie), data=data, timeout=timeout, + json=json, proxies=proxies, params=params, ) @@ -191,6 +193,7 @@ class PtSpider: timeout=timeout, proxies=proxies, params=params, + json=json, ) def ocr_captcha(self, img_url): @@ -386,11 +389,11 @@ class PtSpider: print(submit_name) print(submit_value) headers = { - "mimeType": "application/x-www-form-urlencoded; charset=UTF-8" + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" } - params = [] + param = [] for name, value in zip(submit_name, submit_value): - params.append({ + param.append({ name: value }) data = { @@ -399,25 +402,23 @@ class PtSpider: 'form': form[0], 'message': message, } - i = random.randint(0, 3) - param = '&message={}&req={}&hash={}&form={}&{}={}'.format( - message, req, hash_str, form, submit_name[i], submit_value[i]) - - data.update(params[random.randint(0, 3)]) + data.update(param[random.randint(0, 3)]) print(data) response = self.send_request( my_site, - url=site.url + '?action=show' + param, + url=site.url + site.page_sign_in.lstrip('/') + '?action=show', method=site.sign_in_method, headers=headers, - params=data, data=data, ) print(response.content.decode('utf8')) - return CommonResponse.success(data=response) + if 'response.content.decode("utf8")' in response.content.decode('utf8'): + return CommonResponse.success(msg='低保签到成功!') + else: + return CommonResponse.error(msg='签到失败!') except Exception as e: # raise - return CommonResponse.success( + return CommonResponse.error( status=StatusCodeEnum.WEB_CONNECT_ERR, msg=site.name + str(e) )