Hi i am new to perl I start with perl 3 days ago. I am trying to do a script that connect to a forum and get the latest thread do the same every five minutes and verify if the new thread is not the same as the last one it got from the last login and then save it on a text file (i realy want to send it to mysql database on other comp but i will work on that later)on the new threads info i want to get (description, by who, views, reply, and the link to the thread). I have some thin working but i don't know how to login.
Code:
# Create a user agent object
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
# Create a request
my $req = HTTP::Request->new(POST => '[URL unfurl="true"]http://www.totalfta.com');[/URL]
$req->content_type('application/x-[URL unfurl="true"]www-form-urlencoded');[/URL]
$req->content('query=lib[URL unfurl="true"]www-perl&mode=dist');[/URL]
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
my($text) = $res->content;
if ( $text =~ /<a href="(.+)" title="Go to first unread post in thread '(.+)'"><strong>(.+)<\/strong><\/a>/m ) {
print "[URL unfurl="true"]http://www.totalfta.com/$1,[/URL] $2, $3\n";
}
}
else {
print $res->status_line, "\n";
}