[Chicago-talk] Converting from www::mech to underlying objects

Jay Strauss me at heyjay.com
Mon Feb 14 20:17:00 PST 2005


Awhile back, Leland showed me how to read data from the CBOE site like:

use WWW::Mechanize;
my $url = "http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx";

my $mech = WWW::Mechanize->new();
$mech->agent_alias( 'Windows IE 6' );

$mech->get( $url );
$mech->set_fields( txtTicker => 'QQQQ');
my $form = $mech->current_form;
my $request = $form->click;
$mech->request($request, "QQQQ.txt");

I thought I'd try to fit it into the Finance::Quote namespace as 
Finance::Quote::CBOE.  Finance::Quote doesn't use www::mech, it uses the 
  underlying modules like LWP::UserAgent.  So I'm trying to convert the 
above to work on the more base stuff.  Below is my code, it seems like 
its correct,  but when I run it I get an "Invalid request" back from the 

Could someone give me a nudge in the right direction?


sub option_chain {

    my $quoter = shift;
    $symbol = 'QQQQ';

    my $ua = $quoter->user_agent;
    $ua->agent('Windows IE 6');

    my $response = $ua->get($url);
    my $form = HTML::Form->parse($response->content,

    $form->value(txtTicker => $symbol);

    my $request = $form->click;
    $ua->request($request, "$symbol.txt");

More information about the Chicago-talk mailing list