| 1 | |||
| 2 | package WWW::Scraper::Beaucoup; | ||
| 3 | |||
| 4 | |||
| 5 | ##################################################################### | ||
| 6 | use strict; | ||
| 7 | use vars qw(@ISA $VERSION); | ||
| 8 | @ISA = qw(WWW::Scraper); | ||
| 9 | $VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/); | ||
| 10 | |||
| 11 | use WWW::Scraper(qw(1.48 trimLFs trimLFLFs)); | ||
| 12 | |||
| 13 | # SAMPLE | ||
| 14 | # http://www.Beaucoup.com/js/jobsearch-results.html?loc=CA-San+Jose+Area&cat=Computing%2FMIS-Software+Development&srch=Perl&job=1 | ||
| 15 | my $scraperRequest = | ||
| 16 | { | ||
| 17 | 'type' => 'FORM' # Type of query generation is 'QUERY' | ||
| 18 | # This is the basic URL on which to build the query. | ||
| 19 | ,'url' => 'http://Beaucoup.com' | ||
| 20 | # This is the Scraper attributes => native input fields mapping | ||
| 21 | ,'nativeQuery' => 'q' | ||
| 22 | ,'nativeDefaults' => | ||
| 23 | { 'query' => undef | ||
| 24 | # ,'phrases' => 'off' | ||
| 25 | # ,'rpp' => '10' | ||
| 26 | # ,'cb' => 'Beaucoup' | ||
| 27 | # ,'qtype' => '0' | ||
| 28 | # ,'lang' => '1' | ||
| 29 | # ,'timeout' => '4' | ||
| 30 | ,'Search.x' => 1 | ||
| 31 | ,'Search.y' => 1 | ||
| 32 | } | ||
| 33 | ,'fieldTranslations' => | ||
| 34 | { | ||
| 35 | '*' => | ||
| 36 | { '*' => '*' | ||
| 37 | } | ||
| 38 | } | ||
| 39 | # Some more options for the Scraper operation. | ||
| 40 | ,'cookies' => 0 | ||
| 41 | }; | ||
| 42 | |||
| 43 | my $scraperFrame = | ||
| 44 | [ 'HTML', | ||
| 45 | [ | ||
| 46 | # This page shows <B>1-10</B> out of a total of <B>20</B> results for: | ||
| 47 | [ 'COUNT', 'There are (\d+) results for:' ] | ||
| 48 | ,[ 'COUNT', '\d+-\d+ out of (\d+) for ' ] | ||
| 49 | ,[ 'COUNT', '\d+-\d+ out of a total of (\d+) results for' ] | ||
| 50 | ,[ 'NEXT', 'next' ] | ||
| 51 | ,[ 'HIT*', | ||
| 52 | [ | ||
| 53 | ['REGEX','\d+\.\s<a href="([^"]*)"[^>]*>(.*?)<br>(.*?)<br>', 'url', 'title','description'] | ||
| 54 | |||
| 55 | #1. <a href="/j.php?rc=40&atag=2,,4,da&j=http%3A%2F%2Fgta.sky-scraper.net%2F&kw=scraper">sky-scraper.net: best sites for GRAND THEFT AUTO</a> | ||
| 56 | #<br>sky-scraper.net, Visit Casino On Net and receive up to $200 sign up bonus. Home. Sat, 12 Apr 2003 GMT. ... | ||
| 57 | #<br><i>http://gta.sky-scraper.net/</i> <b><font size=1>(Netscape)</font></b><br><small><a href="/j.php?rc=40&atag=2,,4,da&j=http%3A%2F%2Fgta.sky-scraper.net%2F&kw=scraper" target=_new>Open link in new window</a></small><br><br> | ||
| 58 | ] | ||
| 59 | ] | ||
| 60 | ] | ||
| 61 | ]; | ||
| 62 | |||
| 63 | |||
| 64 | sub testParameters { | ||
| 65 | my ($self) = @_; | ||
| 66 | |||
| 67 | if ( ref $self ) { | ||
| 68 | $self->{'isTesting'} = 1; | ||
| 69 | } | ||
| 70 | |||
| 71 | return { | ||
| 72 | 'SKIP' => &WWW::Scraper::TidyXML::isNotTestable() | ||
| 73 | ,'testNativeQuery' => 'scraper' | ||
| 74 | ,'expectedOnePage' => 5 | ||
| 75 | ,'expectedMultiPage' => 20 | ||
| 76 | ,'expectedBogusPage' => 2000 | ||
| 77 | }; | ||
| 78 | } | ||
| 79 | |||
| 80 | # Access methods for the structural declarations of this Scraper engine. | ||
| 81 | sub scraperRequest { $scraperRequest } | ||
| 82 | sub scraperFrame { $_[0]->SUPER::scraperFrame($scraperFrame); } | ||
| 83 | sub scraperDetail{ undef } | ||
| 84 | |||
| 85 | 1; | ||
| 86 | |||
| 87 | __END__ |