Skip to content

Instantly share code, notes, and snippets.

Created April 6, 2010 05:35
Show Gist options
  • Save anonymous/357253 to your computer and use it in GitHub Desktop.
Save anonymous/357253 to your computer and use it in GitHub Desktop.
/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use HTML::TreeBuilder;
my $agent = WWW::Mechanize->new();
$agent->get("http://www.gumtree.com/london/79/52349379.html");
my $mail2 = get_mail($agent->content);
print $mail2;
sub get_mail {
my $mail = shift;
my $node = HTML::TreeBuilder->new();
$node->parse($mail);
my @class = $node->find_by_attribute('id' => 'posting_details');
my @tables = $class[0]->find_by_attribute('id' => 'desc');
foreach my $table(@tables) {
my $p = $table->look_down(_tag => 'p');
my $email_ref = $p->look_down(_tag => 'a');
my $email = $email_ref->attr('href') if ref $email_ref;
$email = 'n/a' unless ref $email_ref;
#print "$email\n";
}
$node->delete;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment