oa
This commit is contained in:
commit
1090aeac36
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/rayshon_tools.iml" filepath="$PROJECT_DIR$/.idea/rayshon_tools.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/rayshon_tools.iml
generated
Normal file
8
.idea/rayshon_tools.iml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
7
cookies.txt
Normal file
7
cookies.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Netscape HTTP Cookie File
|
||||||
|
# http://curl.haxx.se/rfc/cookie_spec.html
|
||||||
|
# This is a generated file! Do not edit.
|
||||||
|
|
||||||
|
222.240.44.2 FALSE / FALSE ASP.NET_SessionId r3esuett3tcxqtmlqedcxleb
|
||||||
|
222.240.44.2 FALSE / FALSE 253402300799 Login PassWord
|
||||||
|
222.240.44.2 FALSE / FALSE 253402300799 SessionID120082 r3esuett3tcxqtmlqedcxleb
|
||||||
92
oa.py
Normal file
92
oa.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import requests
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import http.cookiejar
|
||||||
|
import base64
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import lxml
|
||||||
|
|
||||||
|
BASE_URL = "http://222.240.44.2:8899/C6/"
|
||||||
|
|
||||||
|
|
||||||
|
class OA:
|
||||||
|
def __init__(self, base_url: str, username: str, pwd: str):
|
||||||
|
self.username = username
|
||||||
|
self.pwd = pwd
|
||||||
|
self.session = requests.session()
|
||||||
|
self.base_url = base_url
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
if os.path.exists("cookies.txt"):
|
||||||
|
|
||||||
|
load_cookiejar = http.cookiejar.MozillaCookieJar()
|
||||||
|
load_cookiejar.load("cookies.txt", ignore_discard=True, ignore_expires=True)
|
||||||
|
load_cookies = requests.utils.dict_from_cookiejar(load_cookiejar)
|
||||||
|
cookies = requests.utils.cookiejar_from_dict(load_cookies)
|
||||||
|
self.session.cookies = cookies
|
||||||
|
|
||||||
|
if not self.session.get(urljoin(self.base_url, "JHSoft.Web.WorkFlat/FlatWorksDone.aspx")).ok:
|
||||||
|
self.__login()
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.__login()
|
||||||
|
|
||||||
|
def __login(self):
|
||||||
|
print("re-login")
|
||||||
|
self.session.cookies = http.cookiejar.MozillaCookieJar(filename="cookies.txt")
|
||||||
|
login_path = urljoin(self.base_url, "JHSoft.Web.Login/AjaxForLogin.aspx")
|
||||||
|
_u = base64.b64encode(self.username.encode('utf-8'))
|
||||||
|
_p = base64.b64encode(self.pwd.encode('utf-8'))
|
||||||
|
|
||||||
|
response = self.session.post(login_path, data={
|
||||||
|
"type": "login",
|
||||||
|
"loginCode": _u,
|
||||||
|
"pwd": _p
|
||||||
|
}, headers={
|
||||||
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
|
})
|
||||||
|
|
||||||
|
if response.ok:
|
||||||
|
print("Login Success: {}".format(self.username))
|
||||||
|
self.session.cookies.save(ignore_expires=True, ignore_discard=True)
|
||||||
|
else:
|
||||||
|
print("Login Failed, error code: {}".format(response.status_code))
|
||||||
|
|
||||||
|
def works(self):
|
||||||
|
u = urljoin(self.base_url, "JHSoft.Web.WorkFlat/FlatWorksDone.aspx")
|
||||||
|
res = self.session.get(u)
|
||||||
|
|
||||||
|
if res.ok:
|
||||||
|
self.parse(res)
|
||||||
|
|
||||||
|
def parse(self, response):
|
||||||
|
|
||||||
|
info_sql = "<root><No djsn='{}'>c2VsZWN0ICogZnJvbSBDdXN0b21Nb2R1bGVfMjAyMTA4MDIwNjAxIHdoZXJlIE1haW5JRD0nSkhDMDAwMzk4MTgn</No><No1>1</No1><No2>-1</No2><No3>MainID;lsh;sqrq;sqr;yggh;bm;zw;qjlx;qjsy;qjksrq;shi1;ksf;qjjsrq;shi2;jsf;gong;tspd</No3></root>"
|
||||||
|
|
||||||
|
soup = BeautifulSoup(response.text, features="lxml")
|
||||||
|
datatable = soup.find(id="DGWorksDone_TBody").find_all("tr")
|
||||||
|
jbtj = filter(lambda x: "JBTJ" in x.text, datatable)
|
||||||
|
qjsq = filter(lambda x: "QJSQ" in x.text, datatable)
|
||||||
|
|
||||||
|
work_overtime = map(lambda x: re.search(re.compile(r"JBTJ\d{8}-\d{4}"), x.text).group(0), jbtj)
|
||||||
|
leave = map(lambda x: re.search(re.compile(r"QJSQ\d{8}-\d{4}"), x.text).group(0), qjsq)
|
||||||
|
|
||||||
|
# for jb in jbtj:
|
||||||
|
cut_path = re.match(re.compile(r"javascript:ClickTitle\('\.\./(.+)'\)"),jbtj.__next__().contents[1].a['onclick']).group(1)
|
||||||
|
djframe_path = urljoin(self.base_url,cut_path)
|
||||||
|
res = self.session.get(djframe_path,allow_redirects=True)
|
||||||
|
if res.ok:
|
||||||
|
print(res.text)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.session.close()
|
||||||
|
|
||||||
|
|
||||||
|
test = OA(BASE_URL, "120082", "7948799")
|
||||||
|
|
||||||
|
test.login()
|
||||||
|
|
||||||
|
test.works()
|
||||||
|
|
||||||
|
test.close()
|
||||||
Loading…
Reference in New Issue
Block a user