Compare commits

..

2 Commits

Author SHA1 Message Date
540d8c4e5b 11 2025-01-07 20:18:34 +08:00
6f3a7c2ecc 11 2025-01-07 18:48:04 +08:00
10 changed files with 52 additions and 55 deletions

View File

@ -26,3 +26,5 @@ $query_string = "create table patient_90(patient_id char(50),patient_name char(5
mysqli_query($link,$query_string);
$query_string = "insert into patient_90 values('123456','王某','1','1')";
mysqli_query($link,$query_string);
echo "表创建成功"

View File

@ -1,3 +1,5 @@
映射URL路径
主配置类
标识一个Java 类是一个控制器
用于标识服务层组件
注入对象

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 602 B

12
ftp.py
View File

@ -14,11 +14,10 @@ def set_proxy(proxy_url):
socket.socket = socks.socksocket
print(f"已设置代理: {proxy_host}:{proxy_port}")
def upload_file_to_ftp(server, username, password, file_path, remote_path, proxy_url=None):
def upload_file_to_ftp(server, username, password, file_path, remote_path):
"""上传单个文件到FTP"""
try:
# 设置代理(如果有的话)
set_proxy(proxy_url)
with ftplib.FTP(server) as ftp:
ftp.login(user=username, passwd=password)
@ -40,12 +39,9 @@ def create_remote_directory(ftp, remote_directory):
ftp.cwd(remote_directory) # 再次进入远程目录
print(f"远程目录 {remote_directory} 已创建!")
def upload_directory_to_ftp(server, username, password, local_directory, remote_directory, proxy_url=None):
def upload_directory_to_ftp(server, username, password, local_directory, remote_directory):
"""上传整个目录及其子目录到FTP服务器"""
try:
# 设置代理(如果有的话)
set_proxy(proxy_url)
with ftplib.FTP(server) as ftp:
ftp.login(user=username, passwd=password)
@ -68,7 +64,7 @@ def upload_directory_to_ftp(server, username, password, local_directory, remote_
local_file_path = os.path.join(root, filename) # 本地文件的完整路径
relative_path = os.path.relpath(local_file_path, local_directory) # 计算相对路径
remote_file_path = os.path.join(remote_directory, relative_path).replace("\\", "/") # 计算远程文件路径
upload_file_to_ftp(server, username, password, local_file_path, remote_file_path, proxy_url) # 上传文件
upload_file_to_ftp(server, username, password, local_file_path, remote_file_path) # 上传文件
except ftplib.all_errors as e:
print(f"上传目录时发生错误: {e}")

91
main.py
View File

@ -12,34 +12,34 @@ import time
import re
import os
import tkinter as tk
from tkinter import messagebox # 单独导入 messagebox
from ftp import set_proxy
from ftp import upload_file_to_ftp
from ftp import upload_directory_to_ftp
from ftp import create_remote_directory
import requests
def launch_proxy():
print("开启代理...")
cmd = "start ./Shadowsocks-4.4.1.0/Shadowsocks.exe"
os.system('chcp 65001')
os.system(cmd)
def close_proxy():
print("杀死代理进程")
cmd = "taskkill /f /im Shadowsocks.exe"
os.system('chcp 65001')
os.system(cmd)
cmd = """
reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
"""
print(cmd)
os.system(cmd)
# def launch_proxy():
# print("开启代理...")
# cmd = "start ./Shadowsocks-4.4.1.0/Shadowsocks.exe"
# os.system('chcp 65001')
# os.system(cmd)
#
# def close_proxy():
# print("杀死代理进程")
# cmd = "taskkill /f /im Shadowsocks.exe"
# os.system('chcp 65001')
# os.system(cmd)
# cmd = """
# reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
# """
# print(cmd)
# os.system(cmd)
def shot(chromedriver_path ,chrome_path):
options = Options()
options.add_experimental_option("detach", True)
options.binary_location = chrome_path
options.add_argument("--no-sandbox")
# 初始化 WebDriver
@ -48,8 +48,6 @@ def shot(chromedriver_path ,chrome_path):
driver.get("http://125.64.9.222:8022/login_exam.php")
try:
launch_proxy()
time.sleep(5)
exam_id = name_entry.get()
@ -129,35 +127,35 @@ def shot(chromedriver_path ,chrome_path):
ftp_username = matches[2]
ftp_password = matches[3]
# 调用上传函数
upload_directory_to_ftp(ftp_server, ftp_username, ftp_password, local_file_path, remote_file_path, proxy_url)
upload_directory_to_ftp(ftp_server, ftp_username, ftp_password, local_file_path, remote_file_path)
url = f"http://{matches[0]}:{matches[1]}/setup_2.php"
response = requests.get(url, cookies=session_cookies)
print(response.raise_for_status())
print(response.text)
# url = f"http://{matches[0]}:{matches[1]}/exam_setup.php"
# response = requests.get(url, cookies=session_cookies)
# print(response.raise_for_status())
# print(response.text)
time.sleep(5)
driver.get("http://125.64.9.222:8022/paper/paper.php")
# 等待页面加载
wait = WebDriverWait(driver, 30)
for fillingQ_id in fillingQ_ids:
textarea = wait.until(EC.presence_of_element_located((By.ID, fillingQ_id)))
with open (fillingQ_path + f"/{fillingQ_id}", "r", encoding="utf-8") as f:
textarea.send_keys(f.read()) # 填写题目
for save in fillingQ_save_ids:
driver.execute_script(f"{save}")
print(f"已保存 {save} 题目")
time.sleep(1)
tk.messagebox.showinfo("提示","执行成功!请手动进入网站点击调试")
except Exception as e:
print(f"发生错误: {e}")
tk.messagebox.showerror("错误", f"发生错误: {e}")
#
# driver.get("http://125.64.9.222:8022/paper/paper.php")
#
# # 等待页面加载
# wait = WebDriverWait(driver, 20)
# for fillingQ_id in fillingQ_ids:
# textarea = wait.until(EC.presence_of_element_located((By.ID, fillingQ_id)))
# with open (fillingQ_path + f"/{fillingQ_id}"+".txt", "r", encoding="utf-8") as f:
# textarea.send_keys(f.read()) # 填写题目
#
# for save in fillingQ_save_ids:
# driver.execute_script(f"{save}")
# print(f"已保存 {save} 题目")
# time.sleep(1)
#
# tk.messagebox.showinfo("提示","执行成功!请手动进入网站点击调试")
# except Exception as e:
# print(f"发生错误: {e}")
# tk.messagebox.showerror("错误", f"发生错误: {e}")
finally:
close_proxy()
driver.quit()
if __name__ == "__main__":
@ -229,5 +227,4 @@ if __name__ == "__main__":
submit_button.pack(side=tk.BOTTOM)
submit_button.config(width=10, height=1)
root.mainloop()
close_proxy()
root.mainloop()