windows - 是否可以使用 ruby​​ 来抓取 Windows 应用程序的屏幕?

标签 windows ruby screen-scraping

我想从 Windows 应用程序中抓取文本数据,以使用现有的 ruby​​ 代码进行其他处理。是否可以使用 Ruby 在 Windows 应用程序中更新数据时抓取数据?我从哪里开始?

最佳答案

如果文本位于标准 Windows 控件中,您可以使用 AutoIt 获取它。它是它自己的脚本语言,您可以在 Ruby 中与其函数进行交互,如下所示:

require 'win32ole'
STDOUT.sync = true

App = "calc.exe"
AppClass = "[CLASS:SciCalc]"    # retrieved with AutoIt Window Info

ai = WIN32OLE.new("AutoItX3.Control")
ai.run( App )
ai.winwaitactive( AppClass )
handle = "[HANDLE:#{ai.wingethandle(AppClass)}]"

until ai.winexists( handle ).zero?
  puts ai.controlgettext( handle, "", "Edit1" ) # retrieved with AutoIt Window Info
  sleep 1
end

这将打开一个“Calc”实例并每秒显示文本控件的内容。

关于windows - 是否可以使用 ruby​​ 来抓取 Windows 应用程序的屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2590475/

相关文章:

c++ - 加载时动态链接库调度

asp.net - 错误 404 on/bin 浏览

windows - 计划任务调用的批处理文件在计划时抛出错误,双击时运行正常

Java 与 Ruby 的 SOAP 处理

ruby-on-rails - 使用 HTTParty 发送多个文件

ruby - 如何使用ruby上传ftp目录

java - 如何使用 htmlunit 更新 html 中的内容?

windows - 当我在 docker 中运行 `docker run hello-world` 时,连接的主机没有响应

python - 是否可以在 heroku 上运行 scrapy?

screen-scraping - Scrapy 如何设置引荐网址