This commit is contained in:
2025-01-07 18:48:04 +08:00
parent 167418b8c8
commit 6f3a7c2ecc
3 changed files with 10 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 699 B

10
ftp.py
View File

@ -14,11 +14,10 @@ def set_proxy(proxy_url):
socket.socket = socks.socksocket socket.socket = socks.socksocket
print(f"已设置代理: {proxy_host}:{proxy_port}") 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""" """上传单个文件到FTP"""
try: try:
# 设置代理(如果有的话)
set_proxy(proxy_url)
with ftplib.FTP(server) as ftp: with ftplib.FTP(server) as ftp:
ftp.login(user=username, passwd=password) ftp.login(user=username, passwd=password)
@ -40,12 +39,9 @@ def create_remote_directory(ftp, remote_directory):
ftp.cwd(remote_directory) # 再次进入远程目录 ftp.cwd(remote_directory) # 再次进入远程目录
print(f"远程目录 {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服务器""" """上传整个目录及其子目录到FTP服务器"""
try: try:
# 设置代理(如果有的话)
set_proxy(proxy_url)
with ftplib.FTP(server) as ftp: with ftplib.FTP(server) as ftp:
ftp.login(user=username, passwd=password) ftp.login(user=username, passwd=password)

13
main.py
View File

@ -16,7 +16,7 @@ from ftp import set_proxy
from ftp import upload_file_to_ftp from ftp import upload_file_to_ftp
from ftp import upload_directory_to_ftp from ftp import upload_directory_to_ftp
from ftp import create_remote_directory from ftp import create_remote_directory
import requests
def launch_proxy(): def launch_proxy():
print("开启代理...") print("开启代理...")
@ -129,12 +129,13 @@ def shot(chromedriver_path ,chrome_path):
ftp_username = matches[2] ftp_username = matches[2]
ftp_password = matches[3] 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) time.sleep(5)
driver.get("http://125.64.9.222:8022/paper/paper.php") driver.get("http://125.64.9.222:8022/paper/paper.php")