Переглянути джерело

Merge branch 'master' of http://8.136.199.33:3000/eta_server/eta_python

hsun 1 рік тому
батько
коміт
aae1532747

+ 47 - 0
lt_api.py

@@ -0,0 +1,47 @@
+import eikon as ek
+
+import hug
+from bottle import route, run
+import json
+import pandas as pd
+import urllib.parse
+
+hug.API(__name__).http.output_format = hug.output_format.json
+
+# 填写路透的key
+key = ""
+
+
+@hug.get('/hz_server')
+def hello():
+    return 'ek true'
+
+
+@hug.get('/edbInfo/ek')
+def GetEdbDataFromEk(EdbCode, StartDate, EndDate):
+    EdbCode = urllib.parse.unquote(EdbCode)
+    print("EdbCode")
+    print(EdbCode)
+    print(StartDate)
+    print(EndDate)
+    print("req start")
+    data = ek.get_timeseries(EdbCode, fields='*', start_date=StartDate, end_date=EndDate)
+    print("result start")
+    print(data)
+    print("是否唯一索引:", data.index.is_unique)
+    if  data.index.is_unique ==False:
+        print("开始去重")
+        data = data.groupby(data.index).first()
+        print("结束去重")
+        print(data)
+    
+    print("result end")
+    dataJson = data.to_json()
+    result = json.loads(dataJson)
+    return result
+
+
+if __name__ == "__main__":
+    ek.set_app_key(key)
+    app = __hug__.http.server()
+    run(app=app, reloader=True, port=7002)

+ 202 - 0
rpa_mysteel_refresh.py

@@ -0,0 +1,202 @@
+import hug
+from bottle import route, run
+import pyautogui
+import random
+import time
+import os
+import win32gui, win32con
+import autoit
+import pyperclip
+import pythoncom
+import datetime
+
+hug.API(__name__).http.output_format = hug.output_format.json
+
+exePath = r"C:\Program Files (x86)\Kingsoft\WPS Office\11.8.2.12085\office6\et"
+# exePath = exePath = r"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
+# exePath = exePath = r"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
+
+
+# 顶部钢联按钮的x,y位置
+gl_button_x = 645
+gl_button_y = 45
+
+# 钢联选项卡下面的刷新按钮的x,y位置
+gl_refresh_button_x = 302
+gl_refresh_button_y = 87
+
+# 获取数据的超时时间(单位:s)
+get_data_timeout_time = 30
+
+# 随机点击的按钮范围
+pointMinX = 200
+pointMaxX = 700
+pointMinY = 300
+pointMaxY = 600
+
+@hug.get('/mysteel_chemical/server')
+def mysteel_chemical_server():
+    return 1
+
+@hug.get('/mysteel_chemical/refresh')
+def mysteel_chemical_refresh(FilePath):
+    screen_width, screen_height = pyautogui.size()
+    print("屏幕分辨率:{} x {}".format(screen_width, screen_height))
+
+    pyautogui.FAILSAFE = False
+    # FilePath = urllib.parse.unquote(FilePath)
+    FilePath = FilePath.replace('"', '')
+
+    pyautogui.hotkey('win', 'd')
+    # time.sleep(2)
+    #
+    # moveX = 1100
+    # moveY = 600
+    # pyautogui.moveTo(moveX, moveY, 0.5)
+    # pyautogui.click(moveX, moveY)
+    try:
+        fileFullPath = FilePath
+        print("fileFullPath start")
+        # print(fileFullPath)
+
+        fileFullPath = fileFullPath.replace("\\\\", "\\")
+
+        # fileFullPath.replace("\\", "\\")
+        # fileFullPath.replace("ppp", "")
+
+        # print("fileFullPath")
+        print(fileFullPath)
+
+        # app = xw.App(visible=True, add_book=False)
+        # app.display_alerts = False
+        # app.screen_updating = True
+        # print("init app")
+        if os.path.exists(fileFullPath) and ".xlsx" in fileFullPath \
+                and fileFullPath.find("~$") < 0 \
+                and fileFullPath.find("template") < 0:
+
+            # 获取文件名和扩展名
+            file_name, file_ext = os.path.splitext(os.path.basename(fileFullPath))
+            file_name_ext = file_name + file_ext
+            print(file_name_ext)
+            print(datetime.datetime.now())
+
+            try:
+                # 打开文件
+                # pythoncom.CoInitialize()
+                # pyautogui.hotkey('win','r')
+                # pyautogui.sleep(0.5)
+                # time.sleep(2)
+                # pyperclip.copy(fileFullPath)
+                # pyautogui.hotkey('ctrl', 'v')
+                # pyautogui.keyDown('enter')
+                # pyautogui.keyUp('enter')
+                # time.sleep(5)
+                #
+                # # open full screen
+                # hwnd = win32gui.GetForegroundWindow()
+                # win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
+                # time.sleep(1)
+
+                # 启动程序
+                code = exePath + " " + fileFullPath
+                # print(code)
+                autoit.run(code)
+                autoit.win_wait_active(file_name_ext, timeout=20)  # 等待窗口激活
+                autoit.win_move(file_name_ext, 0, 0, 1024, 768)
+                # autoit.win_move(file_name_ext, 0, 0, 1920, 1080)
+
+                print("监听成功了")
+
+            except Exception as e:
+                print("打开", fileFullPath, "失败:", e)
+
+                ## 失败的话,截图记录下原因
+                screenshot = pyautogui.screenshot()
+                imgPath = datetime.datetime.now().strftime("%Y%m%d%H%M%S")+"_screenshot_img.png"
+                screenshot.save(imgPath)
+
+                hwnd = win32gui.GetForegroundWindow()
+                found_title = win32gui.GetWindowText(hwnd)
+                print("窗口名称:", found_title)
+                if found_title == "":
+                    print("窗口未打开")
+                    return
+                if found_title.startswith(file_name_ext) == False:
+                    print("窗口与excel不一致,当前窗口:", found_title, ";excel:", file_name_ext)
+                    return
+                autoit.win_move_by_handle(hwnd, 0, 0, 1024, 768)
+                # autoit.win_move_by_handle(hwnd, 0, 0, 1920, 1080)
+
+
+            ### 随机2-3次点击 单元格区域(每次点击停留1s)
+            r = random.randint(2, 3)
+            for i in range(r):
+                pointX = random.randint(pointMinX, pointMaxX)
+                pointY = random.randint(pointMinY, pointMaxY)
+                print("随机点击", i + 1, "下;", "点击X:", pointX, ";Y:", pointY)
+                pyautogui.moveTo(pointX, pointY, 0.5)
+                pyautogui.click()
+                time.sleep(1)
+
+            print("start dataBtn")
+            pyautogui.moveTo(gl_button_x, gl_button_y, 0.5)
+            pyautogui.click()
+            time.sleep(2)
+            print("end dataBtn")
+
+            pointX = random.randint(pointMinX, pointMaxX)
+            pointY = random.randint(pointMinY, pointMaxY)
+            pyautogui.moveTo(pointX, pointY)
+            pyautogui.click()
+            print("点击X:", pointX, ";Y:", pointY)
+
+            # 停留随机秒数
+            sleepSec = random.randint(1, 3)
+            time.sleep(sleepSec)
+
+            pointX = random.randint(pointMinX, pointMaxX)
+            pointY = random.randint(pointMinY, pointMaxY)
+            pyautogui.moveTo(pointX, pointY)
+            pyautogui.click()
+            print("点击X:", pointX, ";Y:", pointY)
+            # 停留随机秒数
+            sleepSec = random.randint(1, 3)
+            time.sleep(sleepSec)
+
+            print("start getCurrentPageData")
+            pyautogui.moveTo(gl_refresh_button_x, gl_refresh_button_y, 1)
+            pyautogui.click()
+            time.sleep(1)
+
+            print("end getCurrentPageData")
+
+            pointX = random.randint(pointMinX, pointMaxX)
+            pointY = random.randint(pointMinY, pointMaxY)
+            pyautogui.moveTo(pointX, pointY, 0.5)
+            pyautogui.click()
+            print("点击X:", pointX, ";Y:", pointY)
+            # 停留等待数据更新
+            time.sleep(get_data_timeout_time)
+
+            pyautogui.hotkey('ctrl', 's')
+            time.sleep(1)
+            pyautogui.hotkey('ctrl', 'w')
+
+            return True
+            # wb.save()
+            #
+            # wb.close()
+        else:
+            print("ext err:" + fileFullPath)
+        # app.kill()
+        return True
+    except Exception as e:
+        print("Exception:")
+        print(str(e))
+        return False
+
+
+if __name__ == "__main__":
+    app = __hug__.http.server()
+    run(app=app, reloader=True, port=7007)

+ 183 - 0
rpa_smm_refresh.py

@@ -0,0 +1,183 @@
+import hug
+from bottle import route, run
+import pyautogui
+import random
+import time
+import os
+import pythoncom
+import win32gui, win32con, win32process
+import pyperclip
+# import psutil
+import urllib.parse
+import autoit
+import datetime
+# import subprocess
+
+hug.API(__name__).http.output_format = hug.output_format.json
+
+exePath = r"C:\Program Files (x86)\Kingsoft\WPS Office\11.8.2.12085\office6\et"
+
+@hug.get('/smm_chemical/server')
+def smm_server():
+    return 1
+
+# 顶部有色按钮的x,y位置
+smm_button_x = 897
+smm_button_y = 53
+
+# 中间更新数据下拉框按钮的x,y位置
+smm_refresh_select_button_x = 212
+smm_refresh_select_button_y = 119
+
+# 中间更新数据按钮的x,y位置
+smm_refresh_button_x = 232
+smm_refresh_button_y = 178
+
+# 超时时间,默认15s
+timeout_time = 15
+
+@hug.get('/smm_chemical/refresh')
+def smm_refresh(file_path):
+    screen_width, screen_height = pyautogui.size()
+    print("当前时间:{};当前屏幕分辨率:{} x {}".format(datetime.datetime.now(), screen_width, screen_height))
+
+    pyautogui.FAILSAFE = False
+
+    file_path = file_path.replace('"', '')
+
+    # 显示桌面
+    pyautogui.hotkey('win', 'd')
+
+    try:
+        file_path = urllib.parse.unquote(file_path)
+        fileFullPath = file_path
+
+        # print("full_path start")
+        fileFullPath = fileFullPath.replace("\\\\", "\\")
+
+        print("文件路径:", fileFullPath)
+
+        if not os.path.exists(fileFullPath):
+            print("文件不存在")
+            return
+
+        if os.path.exists(fileFullPath) and ".xlsx" in fileFullPath \
+                and fileFullPath.find("~$") < 0 \
+                and fileFullPath.find("template") < 0:
+
+            # 获取文件名和扩展名
+            file_name, file_ext = os.path.splitext(os.path.basename(fileFullPath))
+            file_name_ext = file_name + file_ext
+            # print(file_name_ext)
+
+            try:
+
+                # 启动程序
+                code = exePath + " " + fileFullPath
+                # print(code)
+                autoit.run(code)
+                autoit.win_wait_active(file_name_ext, timeout=20)  # 等待窗口激活
+                autoit.win_move(file_name_ext, 0, 0, 1024, 768)
+                # autoit.win_move(file_name_ext, 0, 0, 1920, 1080)
+
+                # print("监听成功了")
+
+            except Exception as e:
+                print("监听", fileFullPath, "失败:", e)
+
+                ## 失败的话,截图记录下原因
+                screenshot = pyautogui.screenshot()
+                imgPath = datetime.datetime.now().strftime("%Y%m%d%H%M%S")+"_screenshot_img.png"
+                screenshot.save(imgPath)
+
+                hwnd = win32gui.GetForegroundWindow()
+                found_title = win32gui.GetWindowText(hwnd)
+                print("当前窗口名称:", found_title)
+                if found_title == "":
+                    print("窗口未打开")
+                    return
+                if found_title.startswith(file_name_ext) == False:
+                    print("当前窗口与excel不一致,当前窗口:", found_title, ";excel:", file_name_ext)
+                    return
+                autoit.win_move_by_handle(hwnd, 0, 0, 1024, 768)
+                # autoit.win_move_by_handle(hwnd, 0, 0, 1920, 1080)
+
+            # 等待自动刷新结束
+            time.sleep(15)
+
+            # 保存
+            pyautogui.hotkey('ctrl', 's')
+            time.sleep(1)
+
+            # 关闭当前excel
+            pyautogui.hotkey('ctrl', 'w')
+
+            return True
+
+            # 屏幕最大化
+            hwnd = win32gui.GetForegroundWindow()
+            win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
+            time.sleep(1)
+
+            # 随机2-3次点击 单元格区域
+            r = random.randint(2, 3)
+            for i in range(r):
+                point_x = random.randint(511, 1745)
+                point_y = random.randint(282, 791)
+                print("随机点击", i + 1, "下")
+                pyautogui.moveTo(point_x, point_y, 0.5)
+                pyautogui.click()
+
+            # 随机停留几秒
+            r = random.randint(1, 2)
+            time.sleep(r)
+
+            # 点击 SMM DATA PRO 按钮
+            # point_x = 541
+            # point_y = 63
+            pyautogui.moveTo(smm_button_x, smm_button_y, 0.5)
+            pyautogui.click()
+            time.sleep(1)
+
+            # 点击 刷新下拉框 按钮
+            # point_x = 210
+            # point_y = 142
+            pyautogui.moveTo(smm_refresh_select_button_x, smm_refresh_select_button_y, 0.5)
+            pyautogui.click()
+            time.sleep(1)
+
+            # 点击 全部工作表 按钮
+            print("开始刷新了")
+            # point_x = 240
+            # point_y = 233
+            pyautogui.moveTo(smm_refresh_button_x, smm_refresh_button_y, 0.5)
+            pyautogui.click()
+            time.sleep(0.5)
+
+            # 点击完刷新按钮后,移开鼠标
+            pyautogui.moveTo(622, 300, 0.5)
+
+            # 等待刷新结束
+            time.sleep(10)
+
+            # 保存
+            pyautogui.hotkey('ctrl', 's')
+            time.sleep(1)
+
+            # 关闭当前excel
+            pyautogui.hotkey('ctrl', 'w')
+
+            return True
+        else:
+            print("ext err:" + fileFullPath)
+
+        return True
+    except Exception as e:
+        print("Exception:")
+        print(str(e))
+        return False
+
+
+if __name__ == "__main__":
+    app = __hug__.http.server()
+    run(app=app, reloader=True, port=7007)

Різницю між файлами не показано, бо вона завелика
+ 17 - 0
yongyi_pig/imgcode_ak.py


+ 29 - 0
yongyi_pig/readme.txt

@@ -0,0 +1,29 @@
+python+selunium定位已打开的浏览器
+参考文档:https://blog.51cto.com/u_15800928/6952328?articleABtest=0
+我们可以利用Chrome DevTools协议。它允许客户检查和调试Chrome浏览器。
+
+1、找到谷歌浏览器的安装地址,并开启一个新的端口,设置一个文件夹保存浏览器的数据
+mac 脚本:
+>/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222  --user-data-dir=/Users/xiexiaoyuan/data/selenium/automationProfile
+
+windows 脚本:
+打开cmd,输入命令:
+>cd C:\Program Files\Google\Chrome\Application\
+>chrome.exe   --remote-debugging-port=9222  --user-data-dir=D:\data\chrome_selunium\automationProfile
+
+-remote-debugging-port值,可以指定任何打开的端口
+-user-data-dir标记,指定创建新Chrome配置文件的目录。它是为了确保在单独的配置文件中启动chrome,不会污染你的默认配置文件。
+
+此时会打开一个浏览器页面,我们输入目标网址,输入账号密码,登录成功。
+登录之后,以后都不需要登录,它会把你这次登录的信息记入到--user-data-dir指定的目录 下
+后面你只需要python+selenium+webdriver定位到这个已经登录的浏览器进行操作就可以啦
+2、运行python脚本: yongyi_pig_manual.py
+
+注意:1、不确定涌溢的网址登录成功后的有效期有多长,目前测试来看至少有1天时间,如果超过登录有效期,需要人工重新登录网页,
+     2、如果本地机器断电重启,即浏览器被关闭,也需要人工重新运行浏览器的脚本
+
+
+python+selunium+第三方服务商识别图片验证码并自动登录
+我测试了20来次,图片验证码的识别准确率有80%,服务费用:0/500次, 298元/3万次
+第三方服务商网址:https://market.aliyun.com/apimarket/detail/cmapi00035185?spm=5176.730005.result.6.3fcb3524emVIdg&accounttraceid=020a0ff01c6848a592d9f028b5356d2chklv
+运行脚本:yongyi_pig.py

+ 185 - 0
yongyi_pig/yongyi_pig.py

@@ -0,0 +1,185 @@
+# coding:utf-8
+from time import sleep
+import datetime
+import openpyxl
+import requests
+from selenium import webdriver
+
+# 设置Chrome浏览器选项
+from selenium.common import exceptions
+from selenium.webdriver.chrome.service import Service
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.wait import WebDriverWait
+
+from imgcode_ak import image_code
+
+"""
+根据table的id属性和table中的某一个元素定位其在table中的位置
+table包括表头,位置坐标都是从1开始算
+tableId:table的id属性
+queryContent:需要确定位置的内容
+"""
+
+
+def get_table_content(driver, tableId, queryContent):
+    # 按行查询表格的数据,取出的数据是一整行,按空格分隔每一列的数据
+    table_tr_list = driver.find_element(By.ID, tableId).find_elements(By.TAG_NAME, "tr")
+    table_list = []  # 存放table数据
+    for tr in table_tr_list:  # 遍历每一个tr
+        # 将每一个tr的数据根据td查询出来,返回结果为list对象
+        table_td_list = tr.find_elements(By.TAG_NAME, "td")
+        row_list = []
+        print(table_td_list)
+        for td in table_td_list:  # 遍历每一个td
+            row_list.append(td.text)  # 取出表格的数据,并放入行列表里
+        table_list.append(row_list)
+
+    # 循环遍历table数据,确定查询数据的位置
+    # for i in range(len(table_list)):
+    #     for j in range(len(table_list[i])):
+    #         if queryContent == table_list[i][j]:
+    #             print("%r坐标为(%r,%r)" % (queryContent, i + 1, j + 1))
+
+
+# 写入文件
+def write_excel_xlsx(path, sheet_name, value):
+    index = len(value)  # 列表中所含元组的个数,从而确定写入Excel的行数
+    # 打开Excel
+    wb = openpyxl.Workbook()
+    # wb = load_workbook(path)
+    sheet = wb.active  # 获得一个的工作表
+    sheet.title = sheet_name
+    # 设置格式
+    sheet.column_dimensions['B'].width = 115
+    # 按行加入
+    for i in range(index):
+        sheet.append(value[i])
+    # 保存文件
+    print(sheet.values)
+    wb.save(path)
+    print("题目写入数据成功!")
+
+
+def send_file(url, file_path):
+    with open(file_path, 'rb') as file:
+        files = {'file': file}
+        response2 = requests.post(url, files=files)
+    return response2
+
+
+def get_element(my_driver, xpaths):
+    """
+    判断是否存在元素并获取元素对象
+    :param my_driver:
+    :param xpaths: xpaths表达式
+    :return: 元素对象或为空
+    """
+    try:
+        target = my_driver.find_element(By.XPATH, xpaths)
+    except exceptions.NoSuchElementException:
+        return False
+    else:
+        return target
+
+
+if __name__ == "__main__":
+    # 创建一个 Chrome WebDriver 实例
+    options = webdriver.ChromeOptions()
+    # options.add_argument("headless")
+    # options.add_argument('--headless')
+    options.add_argument('--disable-gpu')
+    options.add_argument('--no-sandbox')
+    options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, '
+                         'like Gecko) Chrome/118.0.5993.70 Safari/537.36')
+    options.add_argument(" window-size=1920,1080")
+    prefs = {'download.prompt_for_download': False, 'download.default_directory': '/Users/xiexiaoyuan/Downloads/'}
+    options.add_experimental_option('prefs', prefs)
+    s = Service(executable_path='/Users/xiexiaoyuan/chromedriver_mac64_114/chromedriver')
+    # s = Service(executable_path='/Users/xi/Desktop/chromedriver')
+    driver = webdriver.Chrome(service=s, options=options)
+    # driver.maximize_window()
+    driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
+        "source": """
+                            Object.defineProperty(navigator, 'webdriver', {
+                              get: () => undefined
+                            })
+                          """
+    })
+    driver.get('https://data.yongyizixun888.com/index.php?s=member&c=login&m=index')
+    sleep(2)
+
+    admin_name = 'huawen001'
+    admin_pwd = 'abcd1234'
+    table = driver.find_element(By.XPATH, '//*[@id="myform"]/div[3]/div/div[2]/img')
+    table.screenshot(r'pig.png')
+
+    sleep(2)
+    # 解析图片验证码
+    code = image_code('pig.png')
+    if code == "":
+        print("获取图片验证码失败")
+
+    print(code)
+    # 模拟登录
+    # 输入账号
+    username = driver.find_element(By.XPATH, '//*[@id="myform"]/div[1]/div/input')
+    username.send_keys(admin_name)
+    sleep(1)
+    # 输入密码
+    password = driver.find_element(By.XPATH, '//*[@id="myform"]/div[2]/div/input')
+    password.send_keys(admin_pwd)
+    sleep(1)
+    # 输入验证码
+    capter = driver.find_element(By.XPATH, '//*[@id="myform"]/div[3]/div/div[1]/input')
+    capter.send_keys(code)
+
+    sleep(1)
+    # 登录
+    signup = driver.find_element(By.XPATH, '//*[@id="myform"]/div[4]/button')
+    signup.click()
+
+    sleep(5)
+    # 没有登录成功重试
+    account = driver.find_element(By.XPATH, '//*[@id="dr_member_info"]/a[1]').text
+    print(account)
+    if account != admin_name:
+        # 解析图片验证码
+        table = driver.find_element(By.XPATH, '//*[@id="myform"]/div[3]/div/div[2]/img')
+        table.screenshot(r'pig.png')
+        code = image_code('pig.png')
+        if code == "":
+            print("获取图片验证码失败")
+            # 输入验证码
+        capter = driver.find_element(By.XPATH, '//*[@id="myform"]/div[3]/div/div[1]/input')
+        capter.clear()
+        capter.send_keys(code)
+
+        sleep(1)
+        # 登录
+        signup = driver.find_element(By.XPATH, '//*[@id="myform"]/div[4]/button')
+        signup.click()
+
+    sleep(2)
+
+    account = driver.find_element(By.XPATH, '//*[@id="dr_member_info"]/a[1]').text
+    print(account)
+    if account == admin_name:
+        # 跳转首页
+        driver.find_element(By.XPATH, '/html/body/div[1]/div/div/div[3]/ul/li[1]/a').click()
+        sleep(2)
+        a = driver.find_element(By.XPATH, '/html/body/div[4]/div[1]/div[2]/div[2]/a')
+        print(a.get_attribute("href"))
+        a.click()
+
+        # 下载涌溢完整数据库
+        sleep(1)
+        b = driver.find_element(By.XPATH, '/html/body/div[4]/div[1]/div[2]/div[3]/a')
+        print(b.get_attribute("href"))
+        b.click()
+        sleep(10)
+        print("下载成功")
+    else:
+        print("登录失败")
+
+    driver.close()

+ 140 - 0
yongyi_pig/yongyi_pig_manual.py

@@ -0,0 +1,140 @@
+# coding:utf-8
+from time import sleep
+import datetime
+import openpyxl
+import requests
+from selenium import webdriver
+
+# 设置Chrome浏览器选项
+from selenium.common import exceptions
+from selenium.webdriver.chrome.service import Service
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.wait import WebDriverWait
+
+from imgcode_ak import image_code
+
+"""
+根据table的id属性和table中的某一个元素定位其在table中的位置
+table包括表头,位置坐标都是从1开始算
+tableId:table的id属性
+queryContent:需要确定位置的内容
+"""
+
+
+def get_table_content(driver, tableId, queryContent):
+    # 按行查询表格的数据,取出的数据是一整行,按空格分隔每一列的数据
+    table_tr_list = driver.find_element(By.ID, tableId).find_elements(By.TAG_NAME, "tr")
+    table_list = []  # 存放table数据
+    for tr in table_tr_list:  # 遍历每一个tr
+        # 将每一个tr的数据根据td查询出来,返回结果为list对象
+        table_td_list = tr.find_elements(By.TAG_NAME, "td")
+        row_list = []
+        print(table_td_list)
+        for td in table_td_list:  # 遍历每一个td
+            row_list.append(td.text)  # 取出表格的数据,并放入行列表里
+        table_list.append(row_list)
+
+    # 循环遍历table数据,确定查询数据的位置
+    # for i in range(len(table_list)):
+    #     for j in range(len(table_list[i])):
+    #         if queryContent == table_list[i][j]:
+    #             print("%r坐标为(%r,%r)" % (queryContent, i + 1, j + 1))
+
+
+# 写入文件
+def write_excel_xlsx(path, sheet_name, value):
+    index = len(value)  # 列表中所含元组的个数,从而确定写入Excel的行数
+    # 打开Excel
+    wb = openpyxl.Workbook()
+    # wb = load_workbook(path)
+    sheet = wb.active  # 获得一个的工作表
+    sheet.title = sheet_name
+    # 设置格式
+    sheet.column_dimensions['B'].width = 115
+    # 按行加入
+    for i in range(index):
+        sheet.append(value[i])
+    # 保存文件
+    print(sheet.values)
+    wb.save(path)
+    print("题目写入数据成功!")
+
+
+def send_file(url, file_path):
+    with open(file_path, 'rb') as file:
+        files = {'file': file}
+        response2 = requests.post(url, files=files)
+    return response2
+
+
+def get_element(my_driver, xpaths):
+    """
+    判断是否存在元素并获取元素对象
+    :param my_driver:
+    :param xpaths: xpaths表达式
+    :return: 元素对象或为空
+    """
+    try:
+        target = my_driver.find_element(By.XPATH, xpaths)
+    except exceptions.NoSuchElementException:
+        return False
+    else:
+        return target
+
+
+if __name__ == "__main__":
+    # python+selunium定位已打开的浏览器
+    # 创建一个 Chrome WebDriver 实例
+    options = webdriver.ChromeOptions()
+    # options.add_argument("headless")
+    # options.add_argument('--headless')
+    options.add_argument('--disable-gpu')
+    options.add_argument('--no-sandbox')
+    # 谷歌浏览器运行的默认调试端口:先用以下命令启动浏览器
+    # 找到谷歌浏览器的程序地址,开启一个新的端口,并设置一个文件夹来保存浏览器的数据
+    # /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222  --user-data-dir=/Users/xiexiaoyuan/data/selenium/automationProfile
+    # --remote-debugging-port值,可以指定任何打开的端口
+    # --user-data-dir标记,指定创建新Chrome配置文件的目录。它是为了确保在单独的配置文件中启动chrome,不会污染你的默认配置文件。
+    #
+    # 此时会打开一个浏览器页面,我们输入目标网址,输入账号密码,登录成功。
+    # 登录之后,以后都不需要登录,它会把你这次登录的信息记入到 --user-data-dir指定的目录下
+    # 后面你只需要python + selenium + webdriver定位到这个已经登录的浏览器进行操作就可以啦
+    options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
+    # 修改下载地址
+    options.add_argument("--download.default_directory=/Users/xiexiaoyuan/Downloads/")
+    options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, '
+                          'like Gecko) Chrome/118.0.5993.70 Safari/537.36')
+    options.add_argument(" window-size=1920,1080")
+
+    s = Service(executable_path='/Users/xiexiaoyuan/chromedriver_mac64_114/chromedriver')
+    # s = Service(executable_path='/Users/xi/Desktop/chromedriver')
+    driver = webdriver.Chrome(service=s, options=options)
+    # driver.maximize_window()
+    driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
+        "source": """
+                            Object.defineProperty(navigator, 'webdriver', {
+                              get: () => undefined
+                            })
+                          """
+    })
+    driver.get('https://data.yongyizixun888.com/')
+    sleep(3)
+
+    account = driver.find_element(By.XPATH, '//*[@id="dr_member_info"]/a[1]').text
+    print(account)
+
+    # 下载涌溢日度数据库
+    sleep(1)
+    a = driver.find_element(By.XPATH, '/html/body/div[4]/div[1]/div[2]/div[2]/a')
+    print(a.get_attribute("href"))
+    a.click()
+
+    # 下载涌溢完整数据库
+    sleep(1)
+    b = driver.find_element(By.XPATH, '/html/body/div[4]/div[1]/div[2]/div[3]/a')
+    print(b.get_attribute("href"))
+    b.click()
+    sleep(10)
+    # WebDriverWait(driver, 10).until(
+    #     EC.element_to_be_clickable((By.XPATH, '/html/body/div[4]/div[1]/div[2]/div[2]/a'))).click()

Деякі файли не було показано, через те що забагато файлів було змінено