Hi, i am trying to write a script that will navigate through a soccer website to the player of my choice and scrape their info for me. I have the scraping part working by just hard coding an individual player's page in, but trying to implement the navigation is giving me some problems. The website in question is www.soccerbase.com

I have to fill in a form present at the top of the page with the player's name, then submit it for the search. I have tried it two different ways(commenting out one of them) based on info i found online but to no avail. I am an absolute novice when it comes to Perl so any help would be greatly appreciated! Thanks in advance. here is my code:

#!/usr/bin/perl use strict; require WWW::Mechanize; require HTML::TokeParser; my $player = 'Luis Antonio Valencia'; #die "Must provide a player's name" unless $player ne 1; my $agent = WWW::Mechanize->new(); $agent->get('http://www.soccerbase.com/players/home.sd'); $agent->form_name('headSearch'); $agent->set_fields('searchTeamField', $player); $agent->click_button(name=>"Search"); #$agent->submit_form( # form_number => 1, # fields => { => 'Luis Antonio Valencia', } # ); my $stream = HTML::TokeParser->new(\$agent->{content}); my $player_name; $stream->get_tag("strong"); $player_name = $stream->get_trimmed_text("/strong"); print "\n", "Player Name: ", $player_name, "\n";

ps some things commented out are just still there from other stuff, they can be ignored


In reply to Problems with WWW:Mechanize and a form by conor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.