This commit is contained in:
Armamem0t 2025-08-10 12:17:08 +08:00
commit dfca1928c1
Signed by: minglipro
GPG Key ID: 5F355A77B22AA93B
14 changed files with 355 additions and 0 deletions

8
.idea/autofangche.iml generated Normal file
View 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="Pipenv (autofangche)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

14
.idea/deployment.xml generated Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
<serverData>
<paths name="sever">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>

View File

@ -0,0 +1,21 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="pyqt5-qt5" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="PyPep8NamingInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

10
.idea/material_theme_project_new.xml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="94248e5:19892312c9e:-7ff9" />
</MTProjectMetadataState>
</option>
</component>
</project>

7
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Pipenv (autofangche)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Pipenv (autofangche)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View 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/autofangche.iml" filepath="$PROJECT_DIR$/.idea/autofangche.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

129
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="3c80518d-026a-4458-82c2-25ed21399c34" name="更改" comment="">
<change afterPath="$PROJECT_DIR$/.idea/autofangche.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/logger.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$USER_HOME$/AppData/Local/Programs/Python/Python311/Lib/datetime.py" root0="SKIP_INSPECTION" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 6
}</component>
<component name="ProjectId" id="2svDNqSVX1zqeFeDHxO7CmjzZza" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="openDirectoriesWithSingleClick" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showMembers" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Python.main.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;G:/data/python/autofangche&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\data\python\autofangche" />
</key>
</component>
<component name="RunManager">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="autofangche" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.main" />
</list>
</recent_temporary>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-d6986cc7102b-e03c56caf84a-JavaScript-PY-252.23892.439" />
<option value="bundled-python-sdk-b3ae9b5d7125-f0eec537fc84-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-252.23892.439" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="3c80518d-026a-4458-82c2-25ed21399c34" name="更改" comment="" />
<created>1739327117909</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1739327117909</updated>
<workItem from="1739327119092" duration="4683000" />
<workItem from="1739339621164" duration="3338000" />
<workItem from="1739411410609" duration="49000" />
<workItem from="1739432094188" duration="60000" />
<workItem from="1740012240510" duration="52000" />
<workItem from="1740028349103" duration="2498000" />
<workItem from="1740035608829" duration="391000" />
<workItem from="1754797389199" duration="1391000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/autofangche$main.coverage" NAME="main 覆盖结果" MODIFIED="1754798252671" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

12
Pipfile Normal file
View File

@ -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"

21
Pipfile.lock generated Normal file
View File

@ -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": {}
}

Binary file not shown.

33
logger.py Normal file
View File

@ -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="<blue>[{time:%Y-%m-%d %H:%M:%S,%f}]</blue> <green>[{process.name}/{thread.name}/{function}]</green> <red>[{level}]</red> <cyan>{message}</cyan>",
)
logger.add(
stdout(),
format="[{time:%Y-%m-%d %H:%M:%S,%f}] [{process.name}/{thread.name}/{function}] [{level}] {message}",
)

80
main.py Normal file
View File

@ -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()