Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a web page:
http://webpagedirectory/web.html

I would like to run this page once a day. The page updates data for another web page. I would like to create a script to put in my NT task scheduler to run once a day. The only info I can find on doing this is in Perl cookbook with the LWP::RobotUA but not sure if this is the right thing to use. Please advise how I can do this??

Replies are listed 'Best First'.
Re: Automatically run a web page
by Corion (Patriarch) on Apr 21, 2003 at 17:29 UTC

    If you need to automate web tasks, WWW::Mechanize is the way to go. It has an interface much like a command line browser. The code for your problem would be like the following :

    use strict; use WWW::Mechanize; my $agent = WWW::Mechanize->new(); $agent->get('http://webpagedirectory/web.html');
    but as long as you only need to request that one page once a day, LWP::Simple is even simpler :
    use strict; use LWP::Simple; get("http://webpagedirectory/web.html");

    Both modules can be found on the http://www.cpan.org and installed through perl -MCPAN -e "install LWP::Simple" respective perl -MCPAN -e "install WWW::Mechanize".

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
•Re: Automatically run a web page
by merlyn (Sage) on Apr 21, 2003 at 17:41 UTC
    Why is this on a web page? What if it gets hits multiple times in a day?

    If a task isn't providing web content, it doesn't really belong on a web page. Just write a script to perform the actions, and use some sort of scheduling software (cron on Unix, and you said "NT Task Scheduler", so I guess you're on windows) to run the script periodically.

    Do not pervert the web. {grin}

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Thanks for all the input. This is in a cold fusion page and I would have to write a script to execute this:
      <CFSET IndexCollection = "mysearch"> <CFSET IndexDirectory = "C:\Inetpub\wwwroot\searcher"> <CFSET IndexRecurse = "YES"> <CFSET IndexExtensions = ".htm, .html, .pl, *.,.cfm"> <CFSET IndexLanguage = "english"> <CFINDEX collection="#IndexCollection#" action="REFRESH" type="PATH" key="#IndexDirectory#\" extensions="#IndexExtensions#" recurse="#IndexRecurse#" language="#IndexLanguage#" urlPath="http://127.0.0.1/searcher/" > <HTML><HEAD> <TITLE>data</TITLE> <FONT size="+2"><B>Indexing Finished</B></FONT>
      I dont have any idea how I would make this into a script. Currently it runs when I put in the URL in my browser Location/address then it comes back saying "Indexing Finished" and it updates my search web page.
        ColdFusion has a scheduler built in. On the admin page, click on 'Scheduled Tasks' under 'automated tasks'.