For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > November 2005 > unable to post to forum









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author unable to post to forum
perl newbie

2005-11-23, 6:56 pm

I am very new to perl, I am trying to make a post on a forum via perl,
I am getting an error msg that no 'viewtopic' is not found on the page,
but it is clearly there, can someone help me with what is wrong with
the code:


#! Perl\bin\perl -w


use strict;

use WWW::Mechanize;
use HTML::TokeParser;

my $username1 = 'guesthere53';


my $subject = 'interesting';

my $regex = 'viewtopic';

my $message = 'Roy keane was sacked';

my $agent = WWW::Mechanize->new();



$agent->get(my $url =
'http://www.kendaltownfc.co.uk/forum/viewtopic.php?p=5158&sid=ace695a938276dfc744dc4e7e4027097);

my @urls = $agent->find_all_links( url_regex=> qr/viewtopic/);
@urls = map { $_->[0]}@urls;

foreach my $url (@urls)
{
if ( $url =~ m/$regex/ && ( ( $url =~ /$username1/ ) && ( $url =~
/$subject/ ) ) )
{

{ $agent->follow(url_regex => qr/viewtopic/);}
{ $agent->follow(url_regex => qr/newtopic/);}


$agent->form(1);

$agent->field("username", $username1);
$agent->field("subject", $subject);
$agent->field("message", $message);
$agent->click();

}
}

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com