From dfca1928c1275f25373045d8286e1b45812a0464 Mon Sep 17 00:00:00 2001 From: minglipro Date: Sun, 10 Aug 2025 12:17:08 +0800 Subject: [PATCH] a --- .idea/autofangche.iml | 8 ++ .idea/deployment.xml | 14 ++ .idea/inspectionProfiles/Project_Default.xml | 21 +++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/material_theme_project_new.xml | 10 ++ .idea/misc.xml | 7 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 129 ++++++++++++++++++ Pipfile | 12 ++ Pipfile.lock | 21 +++ __pycache__/logger.cpython-311.pyc | Bin 0 -> 1946 bytes logger.py | 33 +++++ main.py | 80 +++++++++++ 14 files changed, 355 insertions(+) create mode 100644 .idea/autofangche.iml create mode 100644 .idea/deployment.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/material_theme_project_new.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 __pycache__/logger.cpython-311.pyc create mode 100644 logger.py create mode 100644 main.py diff --git a/.idea/autofangche.iml b/.idea/autofangche.iml new file mode 100644 index 0000000..8f47036 --- /dev/null +++ b/.idea/autofangche.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..ae196a3 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..c7f70e1 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..a681110 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c52ffdc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1b9e5d6 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..ecf8d7b --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + { + "associatedIndex": 6 +} + + + + { + "keyToString": { + "Python.main.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "master", + "last_opened_file_path": "G:/data/python/autofangche", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + 1739327117909 + + + + + + + + + \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..2ee591a --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple" +verify_ssl = true +name = "pip_conf_index_global" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.11" +python_full_version = "3.11.9" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..7e2dc41 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,21 @@ +{ + "_meta": { + "hash": { + "sha256": "48def127af5914e0bb297b845ac275758feb6e1b89fc8529b834fb09717e192c" + }, + "pipfile-spec": 6, + "requires": { + "python_full_version": "3.11.9", + "python_version": "3.11" + }, + "sources": [ + { + "name": "pip_conf_index_global", + "url": "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": {} +} diff --git a/__pycache__/logger.cpython-311.pyc b/__pycache__/logger.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9519eb45375c65e53b98d9121889d4a670306263 GIT binary patch literal 1946 zcma)7O=ufO6rR~Xtz{{--89h3p@L=uBC(ws3c(SEP^d&oMTy&j6$f>r8U2{mt~3Oiq0>YspqkN@uj+&ikEtpWaBn z$Kz21eCPdG3lY76Bf!b|UKDPHdHj)+Dg2l{YUz9VEE_=BYGLGXS* z0U{#@(LJbWAD(c)PIv*OM*rqwE`@!~a>`}Oif4B5>YwZQ6A*V0MZC_uL@=CDCK8}R zWXPiUn(Gm#?iC05A%IuOD?biIwAarD62aaD&*gz-_ktGO&c<*py8|}+cK#;PFp~|g zlLab7JY(tp_g^$gKTK7s*cY$=B+C_&{?Q%->6=#LozD`V!des{BW!qWx zb=PAhA*!pa>d}iFPU}EDVcV; zSfNYdw>!PE#^T`Jh=t$Rv`ESu$NdAKiT;X@Z{PgwZZ~oJb>hye#GOuJwwsuJow)ZZ zaqrIuokXUa$aE$$FK>1xzHLAJzWrml9j|oam2SKeAUtxtZPj|Q`18y!ne9v`Hrb6$ zwquil3>IM)aKs%?IGpR=yE;8ReXmUz+zB}Np?>ZDE&1@4a(^arIEw*`gPsC2UyDxU zEy?fh0(yaSFHj1zE1+??J;}xaeYIrO-O7L;A#ujs2tX6{^w^ei3`@8(s;?IcwppWv zf*&muY7VJed>tzkeyW>RXc2U?k05|u<#3Gy--+=nEr4fsX91dn8Ay@}>Err5hk(Z~v`+8%F8 zb{)KUSuO|Y9wplPdK*8>wQ|i|Z#34-iUWSvc%FV@)#?1BbsjZmEKV7sS;Bz>t=w~JoYv3Xn=kW4d5Ak3mq zsm0Y?Os0!#raixYc3U>nGeS;DzFu@JhgBQY*GdknnO@`3e;zOSzYheSXJ<$b_JvOS z6evoKF#ZqY%kG*hesSxp9#XA2PnK!X6Aj^OjMki|A-%qA67sL!d8entZkuNYq~q=D zb^+j`VcbI>G{x+pXj9BL=;QYAC(t4o8tO7^{cyy!C+DWC2w!Pxt@xJNL1SGs)<$E2 zCh_P2L=heZmuOFkv>x>0pVvc1ttpvv44;Dkdk I45EYn0q7L8w*UYD literal 0 HcmV?d00001 diff --git a/logger.py b/logger.py new file mode 100644 index 0000000..59a6973 --- /dev/null +++ b/logger.py @@ -0,0 +1,33 @@ +import datetime +import sys + +from loguru import logger + + +class stdout(object): + def write(self, message): + with open('log/' + datetime.datetime.now().strftime("%Y%m%d%H") + ".log", 'a', encoding='utf-8') as f: + f.write(message) + + + def flush(self): + pass + + +logger.remove(0) + + +def printtime(t): + logger.info(t) + return t + + +logger.add( + sys.stdout, + colorize=True, + format="[{time:%Y-%m-%d %H:%M:%S,%f}] [{process.name}/{thread.name}/{function}] [{level}] {message}", + ) +logger.add( + stdout(), + format="[{time:%Y-%m-%d %H:%M:%S,%f}] [{process.name}/{thread.name}/{function}] [{level}] {message}", + ) diff --git a/main.py b/main.py new file mode 100644 index 0000000..32188b7 --- /dev/null +++ b/main.py @@ -0,0 +1,80 @@ +import datetime +import os +import time + +from playwright import sync_api + +from requests import get + +from logger import logger + +os.makedirs("log", exist_ok=True) + +TOKENAPI = "/api/auth/hik/token" + +def TokenData(): + return get(f"https://lida.mingliqiye.com{TOKENAPI}") + +p = sync_api.sync_playwright().start() +browser = p.chromium.launch(channel="msedge", headless=False) +context = browser.new_context() + +cookies_data = [ + { + 'name': 'Admin-Token', + 'value': TokenData().json()['Data']['token'], + 'domain': 'lida.haikewulian.com', + 'path': '/', + 'expires': (datetime.datetime.now() + datetime.timedelta(days=1)).timestamp(), + 'httpOnly': False, + 'secure': False, + 'sameSite': 'Lax' + },{ + 'name': 'Auth', + 'value': 'eyJSZW1iZXJNZSI6eyJzdGF0ZSI6dHJ1ZSwidXNlcm5hbWUiOiJsaWRhIiwicGFzc3dvcmQiOiIwNTA2MDdqaCJ9LCJUb2tlbiI6eyJ0eXBlIjoiIiwiZGF0YSI6IiJ9fQ==', + 'domain': 'lida.mingliqiye.com', + 'path': '/', + 'expires': (datetime.datetime.now() + datetime.timedelta(days=1)).timestamp(), + 'httpOnly': False, + 'secure': False, + 'sameSite': 'Lax' + }, +] + +context.add_cookies(cookies_data) + +page = context.new_page() +page.goto("http://lida.haikewulian.com/weighthouse/poundList") + +def taigan(): + get("http://192.168.127.245:8184/gate-operate/?a=1&channelNo=CNZEQ070108WE06") + +def fangche(): + page.locator(".btn1").click() + time.sleep(0.1) + page.locator('button[class="el-button el-button--success el-button--medium"]').click() + print(page.locator('input[placeholder="请输入车牌号"]').text_content()) + pass + +fangche() +def bucai(): + page.locator(".btn2").click() + time.sleep(5) + pass +haiguanold = '' +while True: + time.sleep(1) + haiguan = page.locator('span[class="el-tooltip call-tip el-tag el-tag--medium el-tag--light"]').text_content() + if haiguan != haiguanold: + haiguanold = haiguan + logger.info(haiguan) + if "车辆状态错误:车辆当前状态为【已入场】" in haiguan: + fangche() + taigan() + elif "海关放行" in haiguan: + fangche() + elif "读取不到货物运输批次提单信息" in haiguan: + fangche() + taigan() + elif "过卡车辆称重与申报空车重量不符:过卡车辆称重与申报空车重量不符" in haiguan: + bucai()