Skip to content

Fast and Dirty Screen Scraping

This example will only work on a  mac, and by itself does not offer an end-to-end and robust screen scraping solution. Nevertheless I believe it serves as a very good example of what you can achieve without writing a single line of code, if you are familiar with your business domain and the tools available to you.

This example assumes that you use Textmate and Macports, because many developers using Macs do. if you do not though, you may install gocr manually, and amend the script accordingly. The main point here is not the script itself, but the thought process leading to it:

# install gocr
sudo port install gocr
# Grab a screenshot, read it, and open it in your editor
screencapture $imgpath
gocr $imgpath > $txtpath
mate $txtpath

Understanding the tools your platform of choice provides you with multiplies your coding arsenal. I know from personal experience that developers may come from diverse backgrounds, and for some of them the innards of an operating system might be a mystery, especially if they have no formal IT education. A good pattern to aid you towards getting to better grips with your machine, is to try and automate any action you find yourself doing again and again. Doing something three times means it is time for you to practice your scripting skills, and learn something valuable in the process.

By the way, the above is also quite easily achievable on Win32 systems. Anyone know how?

Categories: Tricks.

Tags: , , , ,

Comment Feed

No Responses (yet)

Some HTML is OK

or, reply to this post via trackback.