nosbod has asked for the wisdom of the Perl Monks concerning the following question:

Hi
i'm trying to enter some multipart form-data and pull back the results with the following:
use strict; use HTML::Form; use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Cookies; my $ua = LWP::UserAgent->new(); $ua->requests_redirectable(['POST']); # Setup cookie jar $ua->cookie_jar(HTTP::Cookies->new(file=>'/tmp/cookie_jar')); # Give the browser a name $ua->agent("Netscape/7.2"); # Set the timeout value - only wait 60 seconds. $ua->timeout(180); my %form={"genotypeSource"=>"pga", "nickGene"=>"a4galt", "nickPopulation"=>"All", "outputBy"=>"Local_Position", "displayBy"=>"Table/Image", "freq"=>"0", "noMonomorphic"=>"", "clusterSnp"=>"", "clusterSample"=>"", "r2Threshold"=>"0.80", "dataCoverageTagSnp"=>"85", "dataCoverageClustering"=>"70", "ldMin"=>"0.1", "ldMax"=>"1.0", "gFetch"=>"Display Genotypes", "ldSelect"=>"Display Tag SNPs", "ldCal"=>"Display Linkage Disequilibrium", "SNPSummary"=>"Display SNP Summary"}; my $request =$ua->post( "http://gvs.gs.washington.edu/GVS/ServletManager", Content =>\%form, C +ontent_Type => 'form-data'); my $content=$request->content; print $content;
I'm getting session expired errors in the returned content. Any ideas? TIA

Replies are listed 'Best First'.
Re: session expired and LWP::UserAgent
by marto (Cardinal) on Jun 26, 2006 at 12:15 UTC
    nosbod,

    Having looked at the url http://gvs.gs.washington.edu/GVS/ErrorPageSessionExpired.jsp they want you to access this form via a central menu on the homepage, where I guess they create a session. Have your mechanize object get the index page, click the link to the appropriate search (pga?) then populate the resultant form and submit.

    Update: in my haste I forgot to mention that I would use WWW::Mechanize for this task. The documentation is great and has example code you could easily adapt for this task.

    Hope this helps.

    Martin
      fantastic, thanks!