#!/usr/local/bin/perl -w # $Id$ # # Tatsuhiko Miyagawa # EDGE, Co.,Ltd. # use strict; use WWW::Mechanize; use Template; our $Username = "your-username"; our $Password = "your-password"; our $SearchId = "saved-search-name"; my @keys = qw(table image uid name attr country fans_and_path interest); chomp(my $re = <<'RE'); ( .*? .*? .*?(.*?)
(.*?)
(.*?) .*?(.*?)(?:interested in:
(.*?))? .*?) RE ; use Data::Dumper; $Data::Dumper::Indent = 1; my $start = "http://www.orkut.com/"; my $mech = WWW::Mechanize->new(); $mech->agent_alias('Windows IE 6'); $mech->get($start); $mech->form_number(1); $mech->field(u => $Username); $mech->field(p => $Password); $mech->click(); $mech->follow_link(url_regex => qr/Search\.aspx/); $mech->form_number(1); $mech->field(dropdownSavedSearch => $SearchId); { local $^W; $mech->field(__EVENTTARGET => 'dropdownSavedSearch') } $mech->click(); # trim CR my $body = $mech->content(); $body =~ tr/\r//d; my @people; while ($body =~ /$re/gs) { my %data; @data{@keys} = ($1, $2, $3, $4, $5, $6, $7); $data{table} =~ s!( orkut Search: [% id %] http://www.orkut.com/ Orkut Search Results for "[% id %]" [% FOREACH people -%] [%- END %] [% FOREACH people -%] [% name %] http://www.orkut.com/Profile.aspx?uid=[% uid %]> [% table %]]]> [%- END %] TEMPLATE ; my $tt = Template->new(); $tt->process(\$template, { people => \@people, id => $SearchId }) or die $tt->error;