前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >AI炒股:批量下载东方财富choice中的投资数据

AI炒股:批量下载东方财富choice中的投资数据

作者头像
AIGC部落
发布2024-06-24 19:21:39
540
发布2024-06-24 19:21:39
举报
文章被收录于专栏:Dance with GenAIDance with GenAI

工作任务:批量下载东方财富choice中的创投数据

在ChatGPT中输入提示词:

你是一个Python编程专家,写一个关于键盘鼠标自动化操作的Python脚本,具体步骤如下:

打开东方财富choice软件,软件路径为:"D:\Program Files (x86)\Eastmoney\Choice\ChoiceLoader.exe"

暂停20秒,等待程序加载;

鼠标左键点击坐标:254, 16;(注释:股票)

暂停5秒,等待程序加载;

鼠标左键点击坐标:308, 331;(注释:专项应用)

暂停5秒,等待程序加载;

鼠标左键点击坐标:472, 472;(注释:创投数据)

暂停5秒,等待程序加载;

鼠标左键点击坐标:1293, 942;(注释:每页)

暂停5秒,等待程序加载;

鼠标左键点击坐标:1270,897;(注释:100条/每页)

暂停5秒,等待程序加载;

循环执行下面【】里面的步骤15次:

【鼠标左键点击坐标:1841, 168;(注释:导出Excel)

暂停10秒,等待程序加载;

鼠标左键点击坐标:864, 477;(注释:文件名)

暂停5秒,等待程序加载;

键盘输入数字:{number}({number}的值从1开始,以1递增,到15结束)

暂停5秒,等待程序加载;

鼠标左键点击坐标:1125, 618;(注释:保存Excel文件到电脑)

暂停10秒,等待程序加载;

用pyautogui库检查当前页面的区域(左上角坐标是:1114,881,右下角坐标是:1296,969)是否和图片""F:\aivideo\next.jpg""一致的按钮,pyautogui.locateOnScreen函数的参数confidence为0.8,如果有,就模拟鼠标左键点击;(注释:点击下一页)

按下回车键;

暂停5秒,等待程序加载;】

关闭东方财富choice软件;

注意:每一步动作都输出信息到屏幕上

Python源代码如下:

import pyautogui

import time

import subprocess

def open_program(path):

print(f"Opening program: {path}")

subprocess.Popen(path)

time.sleep(20) # Pause to wait for the program to load

def click_at(x, y, description):

print(f"Clicking at ({x}, {y}) - {description}")

pyautogui.click(x, y)

time.sleep(5) # Pause to wait for the action to complete

def type_text(text):

print(f"Typing text: {text}")

pyautogui.typewrite(str(text))

time.sleep(5) # Pause to wait for the typing to complete

def press_enter():

print("Pressing Enter key")

pyautogui.press('enter')

time.sleep(5) # Pause to wait for the action to complete

def check_and_click_image(image_path, region):

print(f"Checking for image: {image_path} in region: {region}")

location = pyautogui.locateOnScreen(image_path, confidence=0.8, region=region)

if location is not None:

print("Image found, clicking on it.")

pyautogui.click(location)

time.sleep(5) # Pause to wait for the action to complete

else:

print("Image not found.")

def main():

program_path = "D:\\Program Files (x86)\\Eastmoney\\Choice\\ChoiceLoader.exe"

open_program(program_path)

click_at(254, 16, "股票")

click_at(308, 331, "专项应用")

click_at(472, 472, "创投数据")

click_at(1293, 942, "每页")

click_at(1270, 897, "100条/每页")

for number in range(1, 16):

click_at(1841, 168, "导出Excel")

time.sleep(10) # Extra wait for export dialog

click_at(864, 477, "文件名")

type_text(number)

click_at(1125, 618, "保存Excel文件到电脑")

time.sleep(10) # Extra wait for save action

check_and_click_image("F:\\aivideo\\next.jpg", region=(1114, 881, 182, 88))

press_enter()

print("Closing the program.")

pyautogui.hotkey('alt', 'f4')

if __name__ == "__main__":

main()

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-05-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Dance with GenAI 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档