| 1 | |||
| 2 | package WWW::Scraper::NorthernLight; | ||
| 3 | |||
| 4 | ##################################################################### | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use vars qw($VERSION @ISA); | ||
| 8 | @ISA = qw(WWW::Scraper); | ||
| 9 | $VERSION = sprintf("%d.%02d", q$Revision: 1.0 $ =~ /(\d+)\.(\d+)/); | ||
| 10 | |||
| 11 | use Carp (); | ||
| 12 | use WWW::Scraper(qw(2.27 generic_option addURL trimTags)); | ||
| 13 | use WWW::Scraper::FieldTranslation; | ||
| 14 | |||
| 15 | my $scraperRequest = | ||
| 16 | { | ||
| 17 | 'type' => 'FORM' # Type of query generation is 'QUERY' | ||
| 18 | ,'formNameOrNumber' => 'powSearch' | ||
| 19 | ,'submitButton' => 'search' | ||
| 20 | # This is the basic URL on which to build the query. | ||
| 21 | ,'url' => 'http://www.northernlight.com/power.html' | ||
| 22 | # This is the Scraper attributes => native input fields mapping | ||
| 23 | ,'nativeQuery' => 'qr' | ||
| 24 | ,'nativeDefaults' => { | ||
| 25 | 'qr' => undef | ||
| 26 | } | ||
| 27 | ,'fieldTranslations' => | ||
| 28 | { | ||
| 29 | '*' => | ||
| 30 | { 'skills' => 'qr' | ||
| 31 | # ,'payrate' => undef | ||
| 32 | # ,'locations' => new WWW::Scraper::FieldTranslation('NorthernLight', 'Job', 'locations') | ||
| 33 | ,'*' => '*' | ||
| 34 | } | ||
| 35 | } | ||
| 36 | # Some more options for the Scraper operation. | ||
| 37 | ,'cookies' => 0 | ||
| 38 | }; | ||
| 39 | |||
| 40 | my $scraperFrame = | ||
| 41 | [ 'HTML', | ||
| 42 | [ | ||
| 43 | # </b> found <b>10,032,977 items</b> | ||
| 44 | [ 'COUNT', 'found\s+<b>([0-9,]+)\s+items?</b>'] | ||
| 45 | ,[ 'NEXT', 'alt="Next Page"' ] | ||
| 46 | ,[ 'BODY', '<!--NLBannerStart-->', '<!--NLResultListEnd-->', | ||
| 47 | [ | ||
| 48 | [ 'HIT*', | ||
| 49 | [ | ||
| 50 | [ 'BODY', '<!--NLResultStart-->', '<!--NLResultEnd-->', | ||
| 51 | [ | ||
| 52 | [ 'TR', | ||
| 53 | [ | ||
| 54 | # <!-- --><!-- <td> </td> --> | ||
| 55 | [ 'SNIP', '<!--[^>]*?<td>.*?-->', | ||
| 56 | [ | ||
| 57 | [ 'TD', | ||
| 58 | [['SPAN', 'number']] | ||
| 59 | ] | ||
| 60 | ,[ 'TD', | ||
| 61 | [ | ||
| 62 | [ 'A', 'url', 'title' ] | ||
| 63 | ,['REGEX', '<!--NLResultRelevanceStart-->(\d+)% -', 'relevance'] | ||
| 64 | ,['REGEX', '<!--NLResultRelevanceEnd-->(.*?) ', 'source'] | ||
| 65 | ,['REGEX', '</b>(.*?)<br>', 'description'] | ||
| 66 | ,['REGEX', '<!-- Misc Block --><!-- \d+ -->(.*?)<!-- Misc Block --><!-- \d+ -->', 'miscBlock'] | ||
| 67 | ,[ 'TABLE', | ||
| 68 | [ | ||
| 69 | ['TR'] | ||
| 70 | ,['REGEX', '(\d+)%:', 'secondRelevance'] | ||
| 71 | ,[ 'A', 'secondUrl', 'secondTitle' ] | ||
| 72 | ] | ||
| 73 | ] | ||
| 74 | #,['SPAN', 'avail'] #needs better treatment of the <SPAN> at the top of this <TD> for this to work. | ||
| 75 | ,[ 'AQ', 'more\s+results', 'moreResultsUrl', undef ] | ||
| 76 | # <!-- Inline Clustering --> | ||
| 77 | ] | ||
| 78 | ] | ||
| 79 | ] | ||
| 80 | ] | ||
| 81 | ] | ||
| 82 | ] | ||
| 83 | ] | ||
| 84 | ] | ||
| 85 | ] | ||
| 86 | ] | ||
| 87 | ] | ||
| 88 | ] | ||
| 89 | ] | ||
| 90 | ]; | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | # Access methods for the structural declarations of this Scraper engine. | ||
| 95 | sub scraperRequest { $scraperRequest } | ||
| 96 | sub scraperFrame { $_[0]->SUPER::scraperFrame($scraperFrame); } | ||
| 97 | sub scraperDetail{ undef } | ||
| 98 | |||
| 99 | sub testParameters { | ||
| 100 | my ($self) = @_; | ||
| 101 | |||
| 102 | if ( ref $self ) { | ||
| 103 | $self->{'isTesting'} = 1; | ||
| 104 | } | ||
| 105 | |||
| 106 | return { | ||
| 107 | 'SKIP' => "NorthernLight's search engine seems to be down these days!?" | ||
| 108 | ,'testNativeQuery' => 'search scraper' | ||
| 109 | ,'expectedOnePage' => 9 | ||
| 110 | ,'expectedMultiPage' => 12 | ||
| 111 | ,'expectedBogusPage' => 0 | ||
| 112 | }; | ||
| 113 | } | ||
| 114 | |||
| 115 | 1; | ||
| 116 | |||
| 117 | |||
| 118 | =pod | ||
| 119 | |||
| 120 | =head1 NAME | ||
| 121 | |||
| 122 | WWW::Scraper::NorthernLight - Scrapes NorthernLight.com | ||
| 123 | |||
| 124 | |||
| 125 | =head1 SYNOPSIS | ||
| 126 | |||
| 127 | require WWW::Scraper; | ||
| 128 | $search = new WWW::Scraper('NorthernLight'); | ||
| 129 | |||
| 130 | |||
| 131 | =head1 DESCRIPTION | ||
| 132 | |||
| 133 | This class is an NorthernLight specialization of WWW::Search. | ||
| 134 | It handles making and interpreting NorthernLight searches | ||
| 135 | F<http://www.NorthernLight.com>. | ||
| 136 | |||
| 137 | This class exports no public interface; all interaction should | ||
| 138 | be done through WWW::Search objects. | ||
| 139 | |||
| 140 | |||
| 141 | =head1 OPTIONS | ||
| 142 | |||
| 143 | None at this time (2001.05.06) | ||
| 144 | |||
| 145 | =over 8 | ||
| 146 | |||
| 147 | =item search_url=URL | ||
| 148 | |||
| 149 | Specifies who to query with the NorthernLight protocol. | ||
| 150 | The default is at | ||
| 151 | http://www.northernlight.com/power.html | ||
| 152 | |||
| 153 | =item search_debug, search_parse_debug, search_ref | ||
| 154 | Specified at L<WWW::Search>. | ||
| 155 | |||
| 156 | =back | ||
| 157 | |||
| 158 | =head1 SEARCH FIELDS | ||
| 159 | |||
| 160 | =head2 displayResultsPerPage - I<Results per Page> | ||
| 161 | |||
| 162 | =over 8 | ||
| 163 | |||
| 164 | =item "5" => 5 | ||
| 165 | |||
| 166 | =item "10" => 10 | ||
| 167 | |||
| 168 | =item "20" => 20 | ||
| 169 | |||
| 170 | =item "50" => 50 | ||
| 171 | |||
| 172 | =item "100" => 100 | ||
| 173 | |||
| 174 | =back | ||
| 175 | |||
| 176 | =head2 postingAge - I<Age of Posting> | ||
| 177 | |||
| 178 | =over 8 | ||
| 179 | |||
| 180 | =item "0" => any time | ||
| 181 | |||
| 182 | =item "1" => 1 day | ||
| 183 | |||
| 184 | =item "3" => 3 days | ||
| 185 | |||
| 186 | =item "7" => 1 week | ||
| 187 | |||
| 188 | =item "8" => 2 weeks | ||
| 189 | |||
| 190 | =item "10" => 1 month | ||
| 191 | |||
| 192 | =back | ||
| 193 | |||
| 194 | =head2 workTermTypeIDs - I<Work Term> | ||
| 195 | |||
| 196 | =over 8 | ||
| 197 | |||
| 198 | =item "1" => Full Time | ||
| 199 | |||
| 200 | =item "2" => Part Time | ||
| 201 | |||
| 202 | =item "3" => Contract | ||
| 203 | |||
| 204 | =item "4" => Temporary/Seasonal | ||
| 205 | |||
| 206 | =item "5" => Internship | ||
| 207 | |||
| 208 | =back | ||
| 209 | |||
| 210 | =head2 countyIDs - I<Job Location-County> | ||
| 211 | |||
| 212 | =over 8 | ||
| 213 | |||
| 214 | =item "0" => Any | ||
| 215 | |||
| 216 | =item "1" => Alameda | ||
| 217 | |||
| 218 | =item "2" => Contra Costa | ||
| 219 | |||
| 220 | =item "3" => Marin | ||
| 221 | |||
| 222 | =item "4" => Napa | ||
| 223 | |||
| 224 | =item "5" => San Benito | ||
| 225 | |||
| 226 | =item "6" => San Francisco | ||
| 227 | |||
| 228 | =item "7" => San Mateo | ||
| 229 | |||
| 230 | =item "8" => Santa Clara | ||
| 231 | |||
| 232 | =item "9" => Santa Cruz | ||
| 233 | |||
| 234 | =item "10" => Solano | ||
| 235 | |||
| 236 | =item "11" => Sonoma | ||
| 237 | |||
| 238 | =item "12" => Other | ||
| 239 | |||
| 240 | =back | ||
| 241 | |||
| 242 | =head2 jobPostingCategoryIDs => I<Job Category> | ||
| 243 | |||
| 244 | =over 8 | ||
| 245 | |||
| 246 | =item "0" => Any | ||
| 247 | |||
| 248 | =item "1" => Accounting/Finance | ||
| 249 | |||
| 250 | =item "2" => Administrative/Clerical | ||
| 251 | |||
| 252 | =item "3" => Advertising | ||
| 253 | |||
| 254 | =item "4" => Aerospace/Aviation | ||
| 255 | |||
| 256 | =item "5" => Agricultural | ||
| 257 | |||
| 258 | =item "6" => Architecture | ||
| 259 | |||
| 260 | =item "7" => Arts/Entertainment | ||
| 261 | |||
| 262 | =item "8" => Assembly | ||
| 263 | |||
| 264 | =item "9" => Audio/Visual | ||
| 265 | |||
| 266 | =item "10" => Automotive | ||
| 267 | |||
| 268 | =item "11" => Banking/Financial Services | ||
| 269 | |||
| 270 | =item "12" => Biotechnology | ||
| 271 | |||
| 272 | =item "13" => Bookkeeping | ||
| 273 | |||
| 274 | =item "14" => Business Development | ||
| 275 | |||
| 276 | =item "15" => Child Care Services | ||
| 277 | |||
| 278 | =item "16" => Colleges & Universities | ||
| 279 | |||
| 280 | =item "17" => Communications/Media | ||
| 281 | |||
| 282 | =item "18" => Computer | ||
| 283 | |||
| 284 | =item "19" => Computer - Hardware | ||
| 285 | |||
| 286 | =item "20" => Computer - Software | ||
| 287 | |||
| 288 | =item "21" => Construction | ||
| 289 | |||
| 290 | =item "22" => Consulting/Professional Services | ||
| 291 | |||
| 292 | =item "23" => Customer Service/Support | ||
| 293 | |||
| 294 | =item "24" => Data Entry/Processing | ||
| 295 | |||
| 296 | =item "25" => Education/Training | ||
| 297 | |||
| 298 | =item "26" => Engineering | ||
| 299 | |||
| 300 | =item "27" => Engineering - Civil | ||
| 301 | |||
| 302 | =item "28" => Engineering - Hardware | ||
| 303 | |||
| 304 | =item "29" => Engineering - Software | ||
| 305 | |||
| 306 | =item "30" => Environmental | ||
| 307 | |||
| 308 | =item "31" => Executive/Management | ||
| 309 | |||
| 310 | =item "32" => Fund Raising/Development | ||
| 311 | |||
| 312 | =item "33" => Government/Civil Service | ||
| 313 | |||
| 314 | =item "34" => Graphic Design | ||
| 315 | |||
| 316 | =item "35" => Health Care/Health Services | ||
| 317 | |||
| 318 | =item "36" => Hospitality/Tourism | ||
| 319 | |||
| 320 | =item "37" => Human Resources | ||
| 321 | |||
| 322 | =item "38" => Information Technology | ||
| 323 | |||
| 324 | =item "39" => Insurance | ||
| 325 | |||
| 326 | =item "40" => Internet/E-Commerce | ||
| 327 | |||
| 328 | =item "41" => Law Enforcement/Security | ||
| 329 | |||
| 330 | =item "42" => Legal | ||
| 331 | |||
| 332 | =item "43" => Maintenance/Custodial | ||
| 333 | |||
| 334 | =item "44" => Manufacturing | ||
| 335 | |||
| 336 | =item "45" => Marketing | ||
| 337 | |||
| 338 | =item "46" => Miscellaneous | ||
| 339 | |||
| 340 | =item "47" => Non-Profit | ||
| 341 | |||
| 342 | =item "48" => Pharmaceutical | ||
| 343 | |||
| 344 | =item "49" => Printing/Publishing | ||
| 345 | |||
| 346 | =item "50" => Property Management/Facilities | ||
| 347 | |||
| 348 | =item "51" => Public Relations | ||
| 349 | |||
| 350 | =item "74" => Purchasing | ||
| 351 | |||
| 352 | =item "52" => QA/QC | ||
| 353 | |||
| 354 | =item "53" => Radio/Television/Film/Video | ||
| 355 | |||
| 356 | =item "54" => Real Estate | ||
| 357 | |||
| 358 | =item "57" => Receptionist | ||
| 359 | |||
| 360 | =item "55" => Recruiting/Staffing | ||
| 361 | |||
| 362 | =item "56" => Research | ||
| 363 | |||
| 364 | =item "58" => Restaurant/Food Service | ||
| 365 | |||
| 366 | =item "59" => Retail | ||
| 367 | |||
| 368 | =item "60" => Sales | ||
| 369 | |||
| 370 | =item "61" => Sales - Inside/Telemarketing | ||
| 371 | |||
| 372 | =item "62" => Sales - Outside | ||
| 373 | |||
| 374 | =item "63" => Security/Investment | ||
| 375 | |||
| 376 | =item "64" => Shipping/Receiving | ||
| 377 | |||
| 378 | =item "65" => Social Work/Services | ||
| 379 | |||
| 380 | =item "66" => Technical Support | ||
| 381 | |||
| 382 | =item "67" => Telecommunications | ||
| 383 | |||
| 384 | =item "68" => Training | ||
| 385 | |||
| 386 | =item "69" => Transportation | ||
| 387 | |||
| 388 | =item "70" => Travel | ||
| 389 | |||
| 390 | =item "71" => Warehouse | ||
| 391 | |||
| 392 | =item "72" => Web Design | ||
| 393 | |||
| 394 | =item "73" => Writer | ||
| 395 | |||
| 396 | =back | ||
| 397 | |||
| 398 | =head1 AUTHOR | ||
| 399 | |||
| 400 | C<WWW::Scraper::NorthernLight> is written and maintained | ||
| 401 | by Glenn Wood, http://search.cpan.org/search?mode=author&query=GLENNWOOD. | ||
| 402 | |||
| 403 | =head1 COPYRIGHT | ||
| 404 | |||
| 405 | Copyright (c) 2001 Glenn Wood | ||
| 406 | All rights reserved. | ||
| 407 | |||
| 408 | This program is free software; you can redistribute it and/or | ||
| 409 | modify it under the same terms as Perl itself. | ||
| 410 | |||
| 411 | |||
| 412 | =cut | ||
| 413 | |||
| 414 | |||
| 415 |