Compare commits
4 Commits
eab1d70061
...
main
Author | SHA1 | Date | |
---|---|---|---|
540d8c4e5b | |||
6f3a7c2ecc | |||
167418b8c8 | |||
2343e8001b |
6
20250103/bootstrap.min.css
vendored
Normal file
6
20250103/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
20250103/bootstrap.min.js
vendored
Normal file
7
20250103/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
20250103/jquery.min.js
vendored
Normal file
5
20250103/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -3,9 +3,9 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>操作表</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<link href="./bootstrap.min.css" rel="stylesheet">
|
||||
<script src="./jquery.min.js"></script>
|
||||
<script src="./bootstrap.min.js"></script>
|
||||
<script>
|
||||
// 确保在文档加载完成后执行
|
||||
$(document).ready(function(operation, table) {
|
||||
@ -42,7 +42,7 @@
|
||||
<button data-operation="del" class="btn btn-danger m-2">drop table</button>
|
||||
<button data-operation="create" class="btn btn-success m-2">create table</button>
|
||||
<button data-operation="select" class="btn btn-primary m-2">select table</button>
|
||||
<select class="form-select m-2 " aria-label="Select table">
|
||||
<select id="mySelect" class="form-select m-2 " aria-label="Select table">
|
||||
<option value="user_70" selected>user_70</option>
|
||||
<option value="nucleic_acid_test_2">nucleic_acid_test_2</option>
|
||||
<option value="patient_90">patient_90</option>
|
||||
|
30
20250103/setup_2.php
Normal file
30
20250103/setup_2.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
include_once("db_config.php");
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
|
||||
$query_string = "create table user_70(name char(50),address char(50),password char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string = "insert into user_70(name,address,password)values('mike','chengdu','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string = "insert into user_70(name,address,password)values('mike','beijing','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string = "insert into user_70(name,address,password)values('tom','chengdu','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string = "insert into user_70(name,address,password)values('rose','chengdu','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$query_string);
|
||||
|
||||
|
||||
$eventTime=mktime(12,12,12,12,12,2022);
|
||||
$query_string = "create table nucleic_acid_test_2(id varchar(50),name varchar(50),address varchar(50),event_time int,insert_time int,code varchar(1))ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string = "insert into nucleic_acid_test_2(id,name,address,event_time,insert_time,code)values('510103199010210012','mike','shanghai',$eventTime,'1597238637','3')";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string ="insert into nucleic_acid_test_2(id,name,address,event_time,insert_time,code)values('510103198310607013','rose','beijing',$eventTime,'1597242237','2')";
|
||||
mysqli_query($link,$query_string);
|
||||
|
||||
$query_string = "create table patient_90(patient_id char(50),patient_name char(50),patient_gender char(1),patient_address char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||
mysqli_query($link,$query_string);
|
||||
$query_string = "insert into patient_90 values('123456','王某','1','1')";
|
||||
mysqli_query($link,$query_string);
|
||||
|
||||
echo "表创建成功"
|
@ -1,3 +1,5 @@
|
||||
映射URL路径
|
||||
主配置类
|
||||
标识一个Java 类是一个控制器
|
||||
用于标识服务层组件
|
||||
注入对象
|
BIN
captcha.png
BIN
captcha.png
Binary file not shown.
Before Width: | Height: | Size: 618 B After Width: | Height: | Size: 602 B |
72
ftp.py
Normal file
72
ftp.py
Normal file
@ -0,0 +1,72 @@
|
||||
import os
|
||||
import ftplib
|
||||
import socks
|
||||
import socket
|
||||
from urllib.parse import urlparse
|
||||
|
||||
def set_proxy(proxy_url):
|
||||
"""设置代理"""
|
||||
if proxy_url:
|
||||
parsed_proxy = urlparse(proxy_url)
|
||||
proxy_host = parsed_proxy.hostname
|
||||
proxy_port = parsed_proxy.port
|
||||
socks.set_default_proxy(socks.SOCKS5, proxy_host, proxy_port) # 可以根据需要调整为 SOCKS5、SOCKS4 或 HTTP
|
||||
socket.socket = socks.socksocket
|
||||
print(f"已设置代理: {proxy_host}:{proxy_port}")
|
||||
|
||||
def upload_file_to_ftp(server, username, password, file_path, remote_path):
|
||||
"""上传单个文件到FTP"""
|
||||
try:
|
||||
|
||||
|
||||
with ftplib.FTP(server) as ftp:
|
||||
ftp.login(user=username, passwd=password)
|
||||
with open(file_path, 'rb') as file:
|
||||
ftp.storbinary(f'STOR {remote_path}', file)
|
||||
print(f"文件 {file_path} 成功上传到 {remote_path}!")
|
||||
|
||||
except ftplib.all_errors as e:
|
||||
print(f"FTP 错误: {e}")
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
|
||||
def create_remote_directory(ftp, remote_directory):
|
||||
"""确保远程目录存在,如果不存在则创建"""
|
||||
try:
|
||||
ftp.cwd(remote_directory) # 尝试进入远程目录
|
||||
except ftplib.error_perm:
|
||||
ftp.mkd(remote_directory) # 如果远程目录不存在,则创建
|
||||
ftp.cwd(remote_directory) # 再次进入远程目录
|
||||
print(f"远程目录 {remote_directory} 已创建!")
|
||||
|
||||
def upload_directory_to_ftp(server, username, password, local_directory, remote_directory):
|
||||
"""上传整个目录及其子目录到FTP服务器"""
|
||||
try:
|
||||
with ftplib.FTP(server) as ftp:
|
||||
ftp.login(user=username, passwd=password)
|
||||
|
||||
# 确保远程目录存在
|
||||
create_remote_directory(ftp, remote_directory)
|
||||
|
||||
# 遍历本地目录树
|
||||
for root, dirs, files in os.walk(local_directory):
|
||||
# 上传子文件夹
|
||||
for dir_name in dirs:
|
||||
remote_dir_path = os.path.join(remote_directory, os.path.relpath(os.path.join(root, dir_name), local_directory)).replace("\\", "/")
|
||||
try:
|
||||
ftp.mkd(remote_dir_path) # 在FTP服务器上创建子目录
|
||||
print(f"已创建远程目录: {remote_dir_path}")
|
||||
except ftplib.error_perm:
|
||||
pass # 如果目录已经存在则忽略
|
||||
|
||||
# 上传文件
|
||||
for filename in files:
|
||||
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) # 上传文件
|
||||
|
||||
except ftplib.all_errors as e:
|
||||
print(f"上传目录时发生错误: {e}")
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
223
main.py
223
main.py
@ -12,130 +12,34 @@ import time
|
||||
import re
|
||||
import os
|
||||
import tkinter as tk
|
||||
import ftplib
|
||||
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 ftp_upload_with_proxy(server, username, password, local_file_path, remote_path, proxy):
|
||||
# """使用 pycurl 上传单个文件到 FTP 服务器"""
|
||||
# buffer = BytesIO()
|
||||
# c = pycurl.Curl()
|
||||
#
|
||||
# # 设置 FTP URL
|
||||
# ftp_url = f'ftp://{server}/{remote_path}'
|
||||
# c.setopt(c.URL, ftp_url)
|
||||
#
|
||||
# # 设置 FTP 认证
|
||||
# c.setopt(c.USERPWD, f"{username}:{password}")
|
||||
# c.setopt(c.READDATA, open(local_file_path, 'rb'))
|
||||
# c.setopt(c.UPLOAD, 1)
|
||||
# c.setopt(c.PREQUOTE, ['PASV'])
|
||||
#
|
||||
# # 设置代理
|
||||
# c.setopt(c.PROXY, proxy)
|
||||
#
|
||||
# try:
|
||||
# c.perform()
|
||||
# print(f"文件 {local_file_path} 成功上传到 {remote_path}!")
|
||||
# except pycurl.error as e:
|
||||
# print(f"FTP 错误: {e}")
|
||||
# finally:
|
||||
# c.close()
|
||||
|
||||
# def upload_directory_to_ftp(server, username, password, local_directory, remote_directory, proxy):
|
||||
# """上传整个目录及其子目录到FTP服务器"""
|
||||
# # 确保远程目录存在
|
||||
# try:
|
||||
# # 此段代码需要检查并创建远程目录
|
||||
# # pycurl 不直接提供创建目录的功能,需要手动实现
|
||||
#
|
||||
# # 上传文件和子目录
|
||||
# for root, dirs, files in os.walk(local_directory):
|
||||
# # 上传子文件夹
|
||||
# for dir_name in dirs:
|
||||
# remote_dir_path = os.path.join(remote_directory,
|
||||
# os.path.relpath(os.path.join(root, dir_name), local_directory)).replace(
|
||||
# "\\", "/")
|
||||
# print(f"准备上传目录: {remote_dir_path}")
|
||||
# # 假设已确认远程目录存在
|
||||
#
|
||||
# # 上传文件
|
||||
# for filename in files:
|
||||
# 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("\\", "/") # 计算远程文件路径
|
||||
#
|
||||
# # 上传文件
|
||||
# ftp_upload_with_proxy(server, username, password, local_file_path, remote_file_path, proxy)
|
||||
#
|
||||
# except Exception as e:
|
||||
# print(f"上传目录时发生错误: {e}")
|
||||
|
||||
def upload_file_to_ftp(server, username, password, file_path, remote_path):
|
||||
try:
|
||||
with ftplib.FTP(server) as ftp:
|
||||
ftp.login(user=username, passwd=password)
|
||||
with open(file_path, 'rb') as file:
|
||||
ftp.storbinary(f'STOR {remote_path}', file)
|
||||
print(f"文件 {file_path} 成功上传到 {remote_path}!")
|
||||
except ftplib.all_errors as e:
|
||||
print(f"FTP 错误: {e}")
|
||||
|
||||
def upload_directory_to_ftp(server, username, password, local_directory, remote_directory):
|
||||
"""上传整个目录及其子目录到FTP服务器"""
|
||||
try:
|
||||
with ftplib.FTP(server) as ftp:
|
||||
ftp.login(user=username, passwd=password)
|
||||
|
||||
# 确保远程目录存在
|
||||
try:
|
||||
ftp.cwd(remote_directory) # 改变到远程目录
|
||||
except ftplib.error_perm:
|
||||
ftp.mkd(remote_directory) # 如果远程目录不存在,则创建
|
||||
ftp.cwd(remote_directory) # 再次进入远程目录
|
||||
|
||||
# 遍历本地目录树
|
||||
for root, dirs, files in os.walk(local_directory):
|
||||
# 上传子文件夹
|
||||
for dir_name in dirs:
|
||||
remote_dir_path = os.path.join(remote_directory, os.path.relpath(os.path.join(root, dir_name), local_directory)).replace("\\", "/")
|
||||
try:
|
||||
ftp.mkd(remote_dir_path) # 在FTP服务器上创建子目录
|
||||
print(f"已创建远程目录: {remote_dir_path}")
|
||||
except ftplib.error_perm:
|
||||
pass # 如果目录已经存在则忽略
|
||||
|
||||
# 上传文件
|
||||
for filename in files:
|
||||
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("\\", "/") # 计算远程文件路径
|
||||
ftp_upload_with_proxy(server, username, password, local_file_path, remote_file_path, proxy_url) # 上传文件
|
||||
|
||||
except ftplib.all_errors as e:
|
||||
print(f"上传目录时发生错误: {e}")
|
||||
|
||||
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 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
|
||||
@ -144,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()
|
||||
@ -225,63 +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(f"http://{matches[0]}:{matches[1]}/setup.html")
|
||||
|
||||
# 等待页面加载完成
|
||||
# WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "kw")))
|
||||
# 输入搜索词
|
||||
try:
|
||||
button = WebDriverWait(driver, 10).until(
|
||||
EC.element_to_be_clickable((By.XPATH, "//button[text()='create table']")) # 使用按钮的文本查找元素
|
||||
)
|
||||
button.click() # 点击按钮
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
finally:
|
||||
result_content = ""
|
||||
try:
|
||||
result_element = WebDriverWait(driver, 100).until(
|
||||
EC.presence_of_element_located((By.ID, "result"))
|
||||
)
|
||||
|
||||
# 获取内容
|
||||
result_content = result_element.text
|
||||
print(f"ID为result的内容: {result_content}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
|
||||
print("执行完毕:" + result_content)
|
||||
|
||||
|
||||
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}.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}")
|
||||
#
|
||||
# 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__":
|
||||
@ -309,6 +183,7 @@ if __name__ == "__main__":
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("一键执行")
|
||||
|
||||
|
||||
# 设置窗口大小
|
||||
window_width = 300
|
||||
@ -352,6 +227,4 @@ if __name__ == "__main__":
|
||||
submit_button.pack(side=tk.BOTTOM)
|
||||
submit_button.config(width=10, height=1)
|
||||
|
||||
|
||||
|
||||
root.mainloop()
|
||||
root.mainloop()
|
Reference in New Issue
Block a user