1 (* Example program which uses Net::Google to query Google.
2 * You will need to have a Google API key in ~/.googlekey for this to work.
3 * Copyright (C) 2003 Merjis Ltd.
4 * $Id: google.ml,v 1.1 2003-10-14 16:05:21 rich Exp $
12 (* This is a hack which shouldn't be needed in future. *)
13 Perl.eval "use Net::Google";
15 (* Load Google API key. *)
16 let home = Sys.getenv "HOME" in
17 let chan = open_in (home ^ "/.googlekey") in
18 let key = input_line chan in
21 (* Create the Google query object. *)
22 let google = Pl_Net_Google.new_ ~key () in
25 let search = google#search () in
26 search#set_query "merjis";
27 search#set_max_results 5;
29 printf "Top 5 results for \"merjis\":\n"; flush stdout;
33 printf "* %s\n <URL:%s>\n\n" response#title response#url