1 / 9

Web Automation

Using Perl to automate web surfing Web Automation Why Automate Surfing? The automatch program #! /usr/bin/perl -w # The 'automatch' program - check a collection of sequences against # the 'mersearchmulti.html' web page. use strict;

Leo
Télécharger la présentation

Web Automation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Perl to automate web surfing Web Automation

  2. Why Automate Surfing?

  3. The automatch program #! /usr/bin/perl -w # The 'automatch' program - check a collection of sequences against # the 'mersearchmulti.html' web page. use strict; use constant URL => "http://pblinux.itcarlow.ie/mersearchmulti.html"; use WWW::Mechanize; my $browser = WWW::Mechanize->new; while ( my $seq = <> ) { chomp( $seq ); print "Now processing: '$seq'.\n";

  4. The automatch program, cont. $browser->get( URL ); $browser->form( 1 ); $browser->field( "shortsequence", $seq ); $browser->submit; if ( $browser->success ) { my $content = $browser->content; while ( $content =~ m[<tr align="CENTER" /><td>(\w+?)</td><td>yes</td>]g ) { print "\tAccession code: $1 matched '$seq'.\n"; } } else { print "Something went wrong: HTTP status code: ", $browser->status, "\n"; } }

  5. Running the automatch program $ chmod +x automatch $ ./automatch sequences.txt

  6. Results from automatch ... Now processing: 'attccgattagggcgta'. Now processing: 'aattc'. Accession code: AF213017 matched 'aattc'. Accession code: J01730 matched 'aattc'. Accession code: M24940 matched 'aattc'. Now processing: 'aatgggc'. Now processing: 'aaattt'. Accession code: AF213017 matched 'aaattt'. Accession code: J01730 matched 'aaattt'. Accession code: M24940 matched 'aaattt'. Now processing: 'acgatccgcaagtagcaacc'. Accession code: M15049 matched 'acgatccgcaagtagcaacc'. Now processing: 'gggcccaaa'. Now processing: 'atcgatcg'. Now processing: 'tcatgcacctgatgaacgtgcaaaaccacag'. Accession code: AF213017 matched 'tcatgcacctgatgaacgtgcaaaaccacag'. . . Now processing: 'ccaaat'. Accession code: AF213017 matched 'ccaaat'. Accession code: J01730 matched 'ccaaat'. Accession code: M24940 matched 'ccaaat'.

  7. figMERSEARCHSOURCE.eps Viewing the source of the mersearchmulti.html web page

  8. Automate repetitive WWW interactions whenever possible Maxim 16.1

  9. Where To From Here

More Related