Just a learner
Just a learner

Reputation: 28572

How to display an image with Perl

I want to write a perl script to auto login a website and do some interesting things. The problem is that the website which I want to log into has a captcha image. I don't have the ability to anticaptcha it, so I need to read the image then display the image to the user to let the user reads the characters on the image, then type the character in the command line back to the program. I want to know, what is the easiest way to display an image to the user?

Thanks.

Upvotes: 4

Views: 5136

Answers (2)

parapura rajkumar
parapura rajkumar

Reputation: 24403

Firstly you can use LWP::Simple to fetch the image and save it to disk.

Afterwards , the simplest thing on Windows is to do

  system("C:\\imagepath\\foo.jpg");

which will show the image in the default application that is used to display it.

On OS X you can do

 system("open ~/imagepath/foo.jpg");

On freedesktop.org standard compliant systems you can do

 system("xdg-open ~/imagepath/foo.jpg");

These involve switching between a command line app and the OS designated application to view the image. If you want it more seamless you can use a Perl GUI library and create a window with downloaded image

Upvotes: 9

user1126070
user1126070

Reputation: 5069

Open in a web page?

Create your application as a web application an simply download the image with LWP then display it in your page (CGI or Dancer, etc.)

You could put a simple text form that let you enter the code.

Upvotes: 1

Related Questions