jekyll has asked for the wisdom of the Perl Monks concerning the following question:
\o,
I need a script to fetch Google results (the unshortened URLs) for some automatism.
However, it looks like Google does not let me do that; not even one single result:
#!/usr/bin/perl use HTML::TreeBuilder::XPath; use HTML::StripTags qw(strip_tags); use strict; use warnings; my $search_url = "https://encrypted.google.com/search?hl=de&q=".$ARGV[ +0]; my $tree = HTML::TreeBuilder::XPath->new_from_url($search_url); my $anchor = $tree->findnodes('//h3[@class="r"]/a'); my $href = URI->new_abs($anchor->[0]->getValue, $search_url); print strip_tags($href,());
> perl moo.pl test GET failed on https://encrypted.google.com/search?hl=de&q=test: 403 Fo +rbidden at moo.pl line 10.
Why? And how can I get the actual result(s) instead?
TIA.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to fetch Google results via TreeBuilder: 403 Forbidden
by Anonymous Monk on Oct 14, 2015 at 09:08 UTC | |
by jekyll (Acolyte) on Oct 14, 2015 at 09:40 UTC |