Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I am interested in writing a perl script that goes to the following link and extracts the number 1975: https://familysearch.org/search/collection/results#count=20&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2%3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2Brace%3AWhite&collection_id=2000219

That website is the amount of white men born in the year 1923 who live in San Diego County, California in 1940. I am trying to do this in a loop structure to generalize over multiple counties and birth years.

I have installed WWW::Mechanize::Firefox.

Here is some code that I have written. I make to the forms section and then I'm completely confused as to what to do. :(

use strict; use warnings; use WWW::Mechanize::Firefox; my $mech = WWW::Mechanize::Firefox->new( activate => 1, # bring the tab to the foreground ); $mech->get('https://familysearch.org/search/collection/results#count=2 +0&query=%2Bevent_place_level_1%3ACalifornia%20%2Bevent_place_level_2% +3A%22San%20Diego%22%20%2Bbirth_year%3A1923-1923~%20%2Bgender%3AM%20%2 +Brace%3AWhite&collection_id=2000219',':content_file' => 'main.html', +synchronize => 0); my $retries = 10; while ($retries-- and $mech->is_visible( xpath => '//*[@id="hourgl +ass"]' )) { print "Sleep until we find the thing\n"; sleep 2; }; die "Timeout while waiting for application" if 0 > $retries; # Now the hourglass is not visible anymore #fill out the search form my @forms = $mech->forms(); #<input id="census_bp" name="birth_place" type="text" tabindex="0"/> + #A selector prefixed with '#' must match the id attribute of the input +. A selector prefixed with '.' matches the class attribute. A selecto +r prefixed with '^' or with no prefix matches the name attribute. $mech->field( birth_place => 'value_for_birth_place' ); # Click on the submit $mech->click({xpath => '//*[@class="form-submit"]'});
Would appreciate any help in getting it to work!

In reply to Scraping using WWW::Mechanize::Firefox by census

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2014-12-25 20:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (163 votes), past polls