login.py
3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import json
import urllib3
from commons import ConfigDB as db
from commons import common as com
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from commons.MyRequest2 import myrequest
#列表查询
class login():
url="http://test.uap.diligrp.com/login/login.action"
header={
"Host": "test.uap.diligrp.com",
"Connection": "keep-alive",
"Content-Length": "33",
"Cache-Control": "max-age=0",
"Upgrade-Insecure-Requests": "1",
"Origin": "http://test.uap.diligrp.com",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.212Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Referer": "http://test.uap.diligrp.com/login/index.html",
"Accept-Encoding": "gzip,deflate",
"Accept-Language": "zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7",
"Cookie": "UAP_accessToken=;UAP_refreshToken=;UAP_loginPath="}
body="userName=sg_wenze&password=111111"
def __init__(self):
self.login_url="test2"
self.url=login.url
self.header=login.header
self.body=login.body
def get_session(self,name,password,**kwargs):
self.body=login.body.replace("sg_wenze", name)
self.body=login.body.replace("111111", password)
self.se=requests.session()
# self.se.post(url=self.url, headers=self.header,data=self.body,**kwargs)
self.se.post(url=login.url, headers=login.header,data=login.body,**kwargs)
return self.se
def get_session2(self,account,**kwargs):
self.body=login.body.replace("sg_wenze", com.get_global_config("account", "account", "sg_username01"))
self.body=login.body.replace("111111", com.get_global_config("account", "account", "sg_password01"))
self.se=requests.session()
# self.se.post(url=self.url, headers=self.header,data=self.body,**kwargs)
self.se.post(url=login.url, headers=login.header,data=login.body,**kwargs)
return self.se
def close_session(self):
print("close session")
self.se.close()
def post(self,name,password,firmid,**kwargs):
self.body=self.body.replace("sg_wenze", name)
self.body=self.body.replace("111111", password)
# re=requests.post(url=self.url, headers=self.header,data=self.body,proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'})
re=requests.post(url=self.url, headers=self.header,data=self.body,**kwargs)
print(re.headers)
return re
# t=login()
#
# t.post("sg_wenze", "111111",proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'})
# def tt(**kwargs):
# print(kwargs)
# t.get_session(http="http://localhost:8888", https="http://localhost:8888")
# t.post("sg_wenze", "1111111",proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'})