fzxiehui / worker_notes

0 stars 0 forks source link

marry #13

Open fzxiehui opened 2 years ago

fzxiehui commented 2 years ago
import requests

# url = "http://193.112.48.37:8080/"
# url = "http://193.112.48.37:8080/api/hrm/login/checkLogin"
url = "http://47.96.101.230:9797/marry_yd/login.jsp"

session = requests.session()

headers = {
   "Content-Type" : "text/html; charset=utf-8",
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/login.jsp"
}

response = session.get(url)

print(response.status_code)
# print(response.text)
print(session.cookies)

url = "http://47.96.101.230:9797/marry_yd/common/showimage.jsp"

response = session.get(url)
# show image
with open("image.jpg", "wb") as f:
    f.write(response.content)

# input image code
image_code = input("input image code: ")

# login
# url = "http://47.96.101.230:7007/marry_yd/loginMarry.do?method=login"
url = "http://47.96.101.230:9797/marry_yd/loginCheck.jsp"
data = {
    "action": "login",
    "username": "kefu6",
    "password": "123qwe!@#",
    "rcode": image_code
}

response = session.post(url, data=data, headers=headers)
print(response.status_code)
print(response.text)
print(session.cookies)

headers = {
   "Content-Type" : "text/html; charset=utf-8",
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/loginCheck.jsp"
}

url = "http://47.96.101.230:9797/marry_yd/loginMarry.do?method=login"
response = session.post(url, data=data,headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/login_marry.do"
response = session.post(url, headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/login_marry.do"

response = session.get(url, headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/top.jsp"
response = session.get(url, headers=headers)
print(response.status_code)
print(response.text)

data = {

   "applyDate": "2022-09-19+01%3A10%3A29",
   "deptCode" : 35010001,
   "deptCodeName" : "%E7%A6%8F%E5%B7%9E%E5%B8%82%E6%B0%91%E6%94%BF%E5%B1%80%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
   "deptCodeNamereset" : "%E7%A6%8F%E5%BB%BA%E7%9C%81%E6%B0%91%E6%94%BF%E5%8E%85%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
   "deptCodereset" : 35000001,
   "nameMan" : "%E6%9E%97%E5%9D%87%E6%BA%A2",
   "opType": "IA",
   "validFlag" : 1

}
url = "http://47.96.101.230:9797/marry_yd/xcdjdj/marryQueryList.do?method=queryList"

# requests = session.post(url=url, data=data, headers=headers)
# print(requests.status_code)
# print(requests.text)

# data = {
#     "loginid" : "zft2765",
#     "userpassword": "xiehui189"
# }

# response = session.post(url, data=data)
# 
# print(response.status_code)
# 
# print(response.text)
# 
# print(session.cookies)
# 
# response = session.get("http://193.112.48.37:8080/api/hrm/login/getAccountList?__random__=1663480088081")
# 
# print(response.status_code)
# print(response.text)
fzxiehui commented 2 years ago
import requests
import time

# url = "http://193.112.48.37:8080/"
# url = "http://193.112.48.37:8080/api/hrm/login/checkLogin"
url = "http://47.96.101.230:9797/marry_yd/login.jsp"

session = requests.session()

headers = {
   "Content-Type" : "text/html; charset=utf-8",
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/login.jsp"
}

response = session.get(url)

print(response.status_code)
# print(response.text)
print(session.cookies)

url = "http://47.96.101.230:9797/marry_yd/common/showimage.jsp"

response = session.get(url)
# show image
with open("image.jpg", "wb") as f:
    f.write(response.content)

# input image code
image_code = input("input image code: ")

# login
# url = "http://47.96.101.230:7007/marry_yd/loginMarry.do?method=login"
url = "http://47.96.101.230:9797/marry_yd/loginCheck.jsp"
data = {
    "action": "login",
    "username": "kefu6",
    "password": "123qwe!@#",
    "rcode": image_code
}

response = session.post(url, data=data, headers=headers)
print(response.status_code)
print(response.text)
print(session.cookies)

headers = {
   "Content-Type" : "text/html; charset=utf-8",
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/loginCheck.jsp"
}

url = "http://47.96.101.230:9797/marry_yd/loginMarry.do?method=login"
response = session.post(url, data=data,headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/login_marry.do"
response = session.post(url, headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/login_marry.do"

response = session.get(url, headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/top.jsp"
response = session.get(url, headers=headers)
print(response.status_code)
print(response.text)

'''

<input type="hidden" name="page_flag" value="true">
<input type="hidden" name="page_order" value="">
<input type="hidden" name="goto_page" value="">
<input type="hidden" name="current_page" value="0">
<input type="hidden" name="total_count" value="0">
<input type="hidden" name="docStatus" value="">
<input type="hidden" name="opDateEnd" value="">
<input type="hidden" name="opType" value="">
<input type="hidden" name="certNumWoman" value="">
<input type="hidden" name="operatorid" value="">
<input type="hidden" name="opflag" value="1">
<input type="hidden" name="certNumMan" value="">
<input type="hidden" name="operatorName" value="">
<input type="hidden" name="nameWoman" value="">
<input type="hidden" name="opDateStart" value="">
<input type="hidden" name="nameMan" value="%E5%BC%A0%E4%B8%89">
<input type="hidden" name="deptCodeName" value="%E7%A6%8F%E5%B7%9E%E5%B8%82%E6%B0%91%E6%94%BF%E5%B1%80%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84">
<input type="hidden" name="deptCode" value="35010001">

'''

# data = {
# 
#     "applyDate": "",
#     "certNumMan": "",
#     "certNumWoman": "",
#     "deptCode" : 35010001,
#     "deptCodeName" : "%E7%A6%8F%E5%B7%9E%E5%B8%82%E6%B0%91%E6%94%BF%E5%B1%80%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
#     "deptCodeNamereset" : "%E7%A6%8F%E5%BB%BA%E7%9C%81%E6%B0%91%E6%94%BF%E5%8E%85%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
#     "deptCodereset" : 35000001,
#     "docStatus" : "",
#     "editflag" : "",
#     "nameMan" : "%E5%BC%A0%E4%B8%89",
#     "nameWoman" : "",
#     "opDateEnd" : "",
#     "opDateStart" : "",
#     "operatorid" : "",
#     "operatorName" : "",
#     "opType" : "IA",
# 
# }
data = {

    "applyDate": "",
   "certNumMan":"",
   "certNumWoman":"", 
   "deptCode": 35000001,
   "deptCodeName": "%E7%A6%8F%E5%BB%BA%E7%9C%81%E6%B0%91%E6%94%BF%E5%8E%85%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84" ,
   "deptCodeNamereset":"%E7%A6%8F%E5%BB%BA%E7%9C%81%E6%B0%91%E6%94%BF%E5%8E%85%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84" ,
   "deptCodereset": 35000001,
   "docStatus":"",
   "editflag":"", 
   "nameMan":"%E5%BC%A0%E4%B8%89",
   "nameWoman":"",
   "opDateEnd":"", 
   "opDateStart":"", 
   "operatorid":"", 
   "operatorName":"",
   "opType": "IA" 

}
url = "http://47.96.101.230:9797/marry_yd/dzgd/marryDzgdcxSq.do?method=querySp&opflag=1&timecode=777b34a84e664f908736e289dd02cf0a"
# url = "http://47.96.101.230:9797/marry_yd/dzgd/marryDzgdList.do?method=queryDzgdList&opflag=1&time={}".format(int(time.time()*1000))
# url = "http://47.96.101.230:9797/marry_yd/xcdjdj/marryQueryList.do?method=queryList"

requests = session.post(url=url, data=data, headers=headers)
print(requests.status_code)
print(requests.text)

headers = {
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/dzgd/marryDzgdcxSq.do?method=querySp&opflag=0&timecode=b028c77c67e43e2a295fefb25fa03b9f"
}

data = {

    "page_flag" :"true",
    "page_order" :"",
    "goto_page" :"",
    "current_page" :"0",
    "total_count" :"0",
    "docStatus" :"",
    "opDateEnd" :"",
    "opType" :"",
    "certNumWoman" :"",
    "operatorid" :"",
    "opflag" :"1",
    "certNumMan" :"",
    "operatorName" :"",
    "nameWoman" :"",
    "opDateStart" :"",
    "nameMan" :"%E5%BC%A0%E4%B8%89",
    "deptCodeName" :"%E7%A6%8F%E5%B7%9E%E5%B8%82%E6%B0%91%E6%94%BF%E5%B1%80%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
    "deptCode" :"35010001"
}

requests = session.post(url=url, data=data, headers=headers)
print(requests.status_code)
print(requests.text)

# data = {
#     "loginid" : "zft2765",
#     "userpassword": "xiehui189"
# }

# response = session.post(url, data=data)
# 
# print(response.status_code)
# 
# print(response.text)
# 
# print(session.cookies)
# 
# response = session.get("http://193.112.48.37:8080/api/hrm/login/getAccountList?__random__=1663480088081")
# 
# print(response.status_code)
# print(response.text)
fzxiehui commented 2 years ago

import requests
import time
import sys

"""
    读取登入页
"""
url = "http://47.96.101.230:9797/marry_yd/login.jsp"

session = requests.session()

headers = {
   "Content-Type" : "text/html; charset=utf-8",
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/login.jsp"
}

response = session.get(url)

# print(response.status_code)
# print(response.text)
# print(session.cookies)

print("========================================================================================================读取登入页:{}".format(response.status_code))
if response.status_code != 200:
    print("读取登入页失败")
    sys.exit(1)

url = "http://47.96.101.230:9797/marry_yd/common/showimage.jsp"

response = session.get(url)
print("========================================================================================================读取验证码:{}".format(response.status_code))

if response.status_code != 200:
    print("读取验证码失败")
    sys.exit(1)

# show image
with open("image.jpg", "wb") as f:
    f.write(response.content)

# show image
import os
os.system("eog image.jpg")

# input image code
image_code = input("input image code: ")

# login
# url = "http://47.96.101.230:7007/marry_yd/loginMarry.do?method=login"
url = "http://47.96.101.230:9797/marry_yd/loginCheck.jsp"
data = {
    "action": "login",
    "username": "kefu6",
    "password": "123qwe!@#",
    "rcode": image_code
}

response = session.post(url, data=data, headers=headers)
print("========================================================================================================验证登入:{}".format(response.status_code))
# print(response.status_code)
# print(response.text)
# print(session.cookies)

headers = {
   "Content-Type" : "text/html; charset=utf-8",
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/loginCheck.jsp"
}

url = "http://47.96.101.230:9797/marry_yd/loginMarry.do?method=login"
response = session.post(url, data=data,headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/login_marry.do"
response = session.post(url, headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/login_marry.do"

response = session.get(url, headers=headers)
print(response.status_code)
print(response.text)

url = "http://47.96.101.230:9797/marry_yd/top.jsp"
response = session.get(url, headers=headers)
print(response.status_code)
print(response.text)

data = {

    "applyDate": "",
    "certNumMan": "",
    "certNumWoman": "",
    "deptCode" : 35010001,
    "deptCodeName" : "%E7%A6%8F%E5%B7%9E%E5%B8%82%E6%B0%91%E6%94%BF%E5%B1%80%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
    "deptCodeNamereset" : "%E7%A6%8F%E5%BB%BA%E7%9C%81%E6%B0%91%E6%94%BF%E5%8E%85%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
    "deptCodereset" : 35000001,
    "docStatus" : "",
    "editflag" : "",
    "nameMan" : "张三",
    "nameWoman" : "",
    "opDateEnd" : "",
    "opDateStart" : "",
    "operatorid" : "",
    "operatorName" : "",
    "opType" : "IA",

}

url = "http://47.96.101.230:9797/marry_yd/dzgd/marryDzgdList.do?method=queryDzgdList&opflag=1&time={}".format(int(time.time()*1000))
# url = "http://47.96.101.230:9797/marry_yd/dzgd/marryDzgdList.do?method=queryDzgdList&opflag=1&time={}".format(int(time.time()*1000))
# url = "http://47.96.101.230:9797/marry_yd/xcdjdj/marryQueryList.do?method=queryList"

requests = session.post(url=url, data=data, headers=headers)
print(requests.status_code)
print(requests.text)

headers = {
   "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
   "Accept-Encoding" : "gzip, deflate",
   "Accept-Language" : "zh-CN",
   "Cache-Control" : "no-cache",
   "Content-Type" : "application/x-www-form-urlencoded",
   "Connection" : "Keep-Alive",
   "Host" : "47.96.101.230:9797",
   "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
   "Referer" : "http://47.96.101.230:9797/marry_yd/dzgd/marryDzgdList.do?method=queryDzgdList&opflag=1&time={}".format(int(time.time()*1000))
}

data = {

    "page_flag" :"true",
    "page_order" :"",
    "goto_page" :"",
    "current_page" :"0",
    "total_count" :"0",
    "docStatus" :"",
    "opDateEnd" :"",
    "opType" :"",
    "certNumWoman" :"",
    "operatorid" :"",
    "opflag" :"1",
    "certNumMan" :"",
    "operatorName" :"",
    "nameWoman" :"",
    "opDateStart" :"",
    "nameMan" :"%E5%BC%A0%E4%B8%89",
    "deptCodeName" :"%E7%A6%8F%E5%B7%9E%E5%B8%82%E6%B0%91%E6%94%BF%E5%B1%80%E5%A9%9A%E5%A7%BB%E7%AE%A1%E7%90%86%E5%A4%84",
    "deptCode" :"35010001"
}

requests = session.post(url=url, data=data, headers=headers)
print(requests.status_code)
print(requests.text)

# data = {
#     "loginid" : "zft2765",
#     "userpassword": "xiehui189"
# }

# response = session.post(url, data=data)
# 
# print(response.status_code)
# 
# print(response.text)
# 
# print(session.cookies)
# 
# response = session.get("http://193.112.48.37:8080/api/hrm/login/getAccountList?__random__=1663480088081")
# 
# print(response.status_code)
# print(response.text)
fzxiehui commented 2 years ago
import requests
import logging
import time
from bs4 import BeautifulSoup

import pandas as pd
# import easyocr

import os

dept_list = [
    {
        "code": 35000001
    },
]

class Marry():

    def __init__(self, url="http://127.0.0.1:9797/") -> None:
        self._base_url = url
        self._session = requests.session()

        self._headers = {
           "Content-Type" : "text/html; charset=utf-8",
           "Accept" : "text/html, application/xhtml+xml, image/jxr, */*",
           "Accept-Encoding" : "gzip, deflate",
           "Accept-Language" : "zh-CN",
           "Cache-Control" : "no-cache",
           "Content-Type" : "application/x-www-form-urlencoded",
           "Connection" : "Keep-Alive",
           "Host" : "47.96.101.230:9797", # @TODO
           "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
           "Referer" : self._base_url + "marry_yd/top.jsp"
        }

    def set_base_url(self, url) -> bool:
        self._base_url = url
        return True

    def login(self, username = "kefu6", password = "123qwe!@#") -> bool:

        # load JSESSIONID from file
        try:
            jsessionid = open("JSESSIONID", "r").read()
            self._session.cookies.set("JSESSIONID", jsessionid)
            # print(self._session.cookies)

        except:
            logging.info("JSESSIONID not found")

        # check login status
        url = self._base_url + "marry_yd/top.jsp"
        response =  self._session.get(url)
        if response.status_code == 200:
            if not "重新登录" in response.text:
                logging.info("login success")
                return True

        logging.info(" 重新登录 ... ")
        logging.info(" 清除JSESSIONID ... ")
        self._session.cookies.clear()
        # get login page
        logging.info(" get login page ... ")

        self._headers["Referer"] = self._base_url + "marry_yd/login.jsp"

        url = self._base_url + "marry_yd/login.jsp"
        response =  self._session.get(url)
        if response.status_code != 200:
            logging.error("get login page failed")
            return False
        # print(response.text)

        logging.info("读取新 JSESSIONID : {}".format(self._session.cookies))

        # 下载验证码
        url = self._base_url + "marry_yd/common/showimage.jsp"
        response = self._session.get(url)
        if response.status_code != 200:
            logging.error("get captcha failed")
            return False

        with open("captcha.jpg", "wb") as f:
            f.write(response.content)

        # 打开验证码
        os.system("eog captcha.jpg")

        image_code = input("请输入验证码:")

        # login
        url = self._base_url + "marry_yd/loginCheck.jsp"
        data = {
            "action" : "login",
            "username" : username,
            "password" : password,
            "rcode" : image_code 
        }
        response = self._session.post(url, data=data, headers=self._headers)
        if response.status_code != 200:
            logging.error("login failed")
            return False

        self._headers["Referer"] = url

        url = self._base_url + "marry_yd/loginMarry.do?method=login"
        response = self._session.post(url, data=data,headers=self._headers)
        if response.status_code != 200:
            logging.error("login failed")
            return False

        self._headers["Referer"] = url

        if "验证码错误" in response.text:
            logging.info("验证码错误")
            return False

        # save JSESSIONID to file
        with open("JSESSIONID", "w") as f:
            f.write(self._session.cookies.get_dict()["JSESSIONID"])

        return True

    def query(self, nameMan = "", nameWoman = "", 
            deptCode = 35010001):

        data = {

            "applyDate": "",
            "certNumMan": "",
            "certNumWoman": "",
            "deptCode" : 35000001,
            "deptCodereset" : 35000001,
            "docStatus" : "",
            "editflag" : "",
            "nameMan" : "{}".format(nameMan),
            "nameWoman" : "{}".format(nameWoman),
            "opDateEnd" : "",
            "opDateStart" : "",
            "operatorid" : "",
            "operatorName" : "",
            "opType" : "IA",

        }
        url = self._base_url + "marry_yd/dzgd/marryDzgdList.do?method=queryDzgdList&opflag=1&time={}".format(int(time.time()*1000))
        response = self._session.post(url, data=data, headers=self._headers)
        if response.status_code != 200:
            logging.error("query failed")
            return False
        soup = BeautifulSoup(response.text, "html.parser")

        table = soup.find_all("table", {"class" : "table1"})

        table = pd.read_html(str(table))[0]
        print(table)

        # with open("query.html", "w") as f:
        #     f.write(response.text)
        # print(soup.prettify())
        # print(response.text)
        # return True

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    marry = Marry(url="http://47.96.101.230:9797/")
    marry.login()
    marry.query("林均溢","黄晓娟")
    pass