After reviewing the
CPAN Perldoc, it looks as though it most certainly should be returning a list back from the method, therefore you should be using it in the correct context. However, it does also note:
The method for specifying link criteria is the same as in find_link().
And, when reviewing the
find_link() method, it looks as though it's implemented such as:
my $agent = WWW::Mechanize->new();
my $link = $agent->find_link( text => "some text", url_regex => qr/s
+omelink\.com/ );
Using this as an example, I would try re-factoring your code to read:
#!/usr/bin/perl
use strict;
use www::mechanize;
my $agent = WWW::Mechanize->new();
my @urls;
my $regex = 'results';
my $url ='http://www.google.co.uk/search?hl=en&safe=off&q=intitle%3A%2
+2football+scores%22+inurl%3Aresults&meta=cr%3DcountryUK%7CcountryGB';
$agent->get($url);
my @urls=$agent->find_all_links(text => "some text", url_regex => qr
+/somelink\.com/);
print stdout "@urls\n";
For the parameters of the method, you may want to take a look at the
Perldoc for the class you are trying to use. There are a number of parameters you can supply, though they must be supplied as defined. Therefore, in your example, it would probably only search for any links that look like '
http://www.google.co.uk/search?hl=en&safe=off&q=intitle%3A%2
+2football+scores%22+inurl%3Aresults&meta=cr%3DcountryUK%7CcountryGB
', which would probably be none in the results.
One last (I swear) thing you might want to take a look at is the
Google API. Although it is a SOAP based API, it is somewhat easy to use and there are already
Perl modules in CPAN that act as wrappers for the API.
Also, maybe take a look into
WWW::Scraper::Google and
DBD::Google. Personally, I have not used them nor looked at the source to see what they are doing. However, if stable, they are most likely doing the same thing you are trying to accomplish.
Good Luck!
---hA||ta----
print map{$_.' '}grep{/\w+/}@{[reverse(qw{Perl Code})]} or die while ( 'trying' );
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.