Rob Dixon wrote: > Mathew Snyder wrote: >> With all the help I've received I've been able to get this working. >> This is my >> text: >> #!/usr/bin/perl >> >> use warnings; >> use strict; >> use WWW::Mechanize; >> use HTML::TokeParser; >> >> my $username = 'msnyder'; >> my $password = 'xxxxxxx'; >> my $status = 'open'; >> >> my $agent = WWW::Mechanize->new(); >> $agent->get('https://rt.ops.xxxxxxxxxxx.com/'); >> >> $agent->submit_form( >> form_name => 'login', >> fields => { >> 'user' => $username, >> 'pass' => $password, >> } >> ); >> >> $agent->follow_link(text => "Tickets"); >> >> $agent->submit_form( >> form_name => 'BuildQuery', >> fields => { >> 'ValueOfStatus' => $status, >> 'ValueOfActor' => $username, >> }, >> button => 'DoSearch' >> ); >> >> my $data = $agent->content(); >> print $data; >> >> >> What this will do is return to me HTML source with a list of work >> tickets and >> all pertinent, associated data. The purpose of setting this up is to >> allow me >> to pull out email addresses of any work ticket created as a result of >> spam. >> >> For anyone not familiar with Request Tracker from Best Practical >> Solutions, the >> 'from' email address on any incoming email received by Request Tracker is >> automatically turned into a user account. With the amount of spam >> flying around >> the the Net these days those user accounts add up. >> >> All those spam tickets are assigned to me so I can eliminate them and >> the users >> created as a result of them from our database. My goal is to parse >> $data to >> pull out all the email addresses which I will then sift through to >> remove any >> legitimate addresses. >> >> You'll notice I declare the use of HTML::TokeParser. This leads to my >> next >> question. Do I need to use that? Would it be simpler to just parse >> the data >> matching against a regex and put any matches into a file? I imagine I >> don't >> need to sift through all the HTML tags just to get to the email >> addresses since >> they are fairly easy to spot. > > Hi Mathew > > Ordinarily I would insist that you use a proper HTML parser, but I see > no harm in > searching for email addresses as their format is well defined. Use the > Email::Address module, like this: > > use Email::Address; > > my @email = Email::Address->parse($agent->content); > print $_->address, "\n" foreach @email; > > HTH, > > Rob >
I guess I've still got to get used to the fact that if there's something I want to do in perl, there's probably a module for it. Thanks. That should be exactly what I need. Mathew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>