Good Evening,
The code i wrote here isn't the best. Please bear with me.
When it executes it spews out a bunch of mechanize warnings which i am not sure what it means.
Execution is by command line
filename.pl user@email.com whateverpassword
This looks at a certain website and grabs all your friends and messages a happy b-day greeting if their b-day is today.
#!/usr/bin/perl -w
use strict;
my $MONTH=qr/(January|February|March|April|May|June|July|August|Septem
+ber|October|November|December)(?=[^a-zA-Z])/;
my @abbr = qw(January February March April May June July August Septem
+ber October November December);
use WWW::Mechanize;
my $url = "http://www.facebook.com";
my $m = WWW::Mechanize->new();
$m->get($url);
$m->submit_form(form_name=>"loginform", fields=>{email=>$ARGV[0], pass
+=>$ARGV[1]});
$m->get("/bdaycal.php");
my $b= $m->content();
$b=~/.... Birthdays(.*?)Facebook /g;
$b=$1;
$b=~s|(http://\w+\.facebook.com/profile\.php\?id=\d+)| > $1_<|g;
$b=~s/<[^>]*>//g;
$b=~s/Give a Birthday Gift \| Post a Birthday Flyer//g;
$b=~s/ //g;
my @C = split /$MONTH/,$b;
shift @C;
my %B=@C;
my $count=0;
my %O;
for (keys %B){
while ($B{$_}=~s/^(\d\d)-(.*?)(\d\d-.*)$/$3/){
my $day = $1*1;
my @T=split ",",$2;
my @S;
foreach my $t(0..$#T){
my ($id,$age,$name);
$id=($T[$t]=~s/([^_]+)_//)?$1:"";
$age=($T[$t]=~s/\(age (\d\d)\)//)?$1:"";
$name=$T[$t];
$O{$_}->{$day}->[$t]= {id=>$id,
age=>$age,
name=>$name };
$count++;
}
}
};
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time
+);
$mon=$abbr[$mon];
for (@{$O{$mon}->{$mday}}){
$m->get($_->{id});
print $_->{name};
my $Form=0;
for ($m->forms){
$Form++;
last if $_->find_input ("wall_text");
}
print ((($m->submit_form(form_number=>$Form, fields=>{wall_text=>"
+Happy Birthday!"}))?" - Success":" - Failed"),"\n");
}
The Errors that it produces:
Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani
+ze.pm line 2055
Use of uninitialized value in substitution iterator at /usr/share/perl
+5/URI/_query.pm line 16.
Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani
+ze.pm line 2055
Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani
+ze.pm line 2055
Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani
+ze.pm line 2055
The warnings seem to come only after get() requests. Any guidance would help. As well this is WWW::Mechanize ver 1.32.
This is also likely something that I should have noticed.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.