login.py
2.59 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
#!/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)
#列表查询
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.url=login.url.replace("test.uap.diligrp.com",com.get_global_config("global_data", "environment", "en") )
self.header=login.header
self.body=login.body
def get_session(self,account,**kwargs):
self.body=self.body.replace("sg_wenze", com.get_global_config("global_data", "account", account).split("&")[0])
self.body=self.body.replace("111111", com.get_global_config("global_data", "account", account).split("&")[1])
self.se=requests.session()
re=self.se.post(url=self.url, headers=self.header,data=self.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,**kwargs)
print(re.headers)
return re
# t=login()
# print(t.url)
# t.get_session2("user01",proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'},allow_redirects=False)
# 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'})