An automation script which continuosly presses a button in a website

97 views Asked by At

There are limited slots in my course and I am missing the slots as they are opening for a few minutes in a day which I am missing.

Hence I plan to write an automation script which at regular interval presses a button in a website. But I have no clue about where to start. Which language offers the best libraries and interfaces to deal with webpages?Any pointers would be helpful.

Also once I write the script code where can I run it so that it can continuously execute at regular intervals throughout the day ?

1

There are 1 answers

0
bytepusher On

Have a look at perl's WWW::Mechanize

The script could look like so:

#!/usr/bin/perl

use strict;
use warnings;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my $uri = "http://www.example.com"
$mech->get( $uri ); # whatever the url of your site is

while( $uri eq $mech->uri ){ 
   # you could also use while(1) to keep going indefinitely
   # I assume you end up on another site once the click was a success

   $mech->click_button({ name => "enter" });
   # there are other ways to find the button, worst case by number 
   # (e.g. 4th button on site ), the documentation is pretty good

   # $mech->back(); #perhaps, if clicking the button at the wrong time 

   sleep(60); #wait a minute...
}

Where to run it, I do not know, sorry ;).