Searching for Special Characters
Search for the tilde and other special characters in URLs.
Google can find lots of different things, but at this writing, it
canât find special characters in its search results.
Thatâs a shame, because special characters can come
in handy. The tilde (~
), for example, denotes
personal web pages.
This hack takes a query from a form, pulls results from Google, and filters the results for the presence of several different special characters in the URL, including the tilde.
Why would you want to do this? By altering this hack slightly (see
Hacking the Hack) you could restrict
your searches to just pages with a tilde in the URL, an easy way to
find personal pages. Maybe youâre looking for
dynamically generated pages with a question mark
(?
) in the URL; you canât find
these using Google by itself, but you can thanks to this hack. And of
course you can turn the hack inside out and not return results
containing ~, ?, or other special characters. In fact, this code is
more of a beginning than an end unto itself; you can tweak it in
several different ways to do several different things.
The Code
#!/usr/local/bin/perl # aunt_tilde.pl # Finding special characters in Google result URLs # Your Google API developer's key my $google_key='insert key here'; # Number of times to loop, retrieving 10 results at a time my $loops = 10; # Location of the GoogleSearch WSDL file my $google_wdsl = "./GoogleSearch.wsdl"; use strict; use CGI qw/:standard/; use SOAP::Lite; ...
Get Google Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.