1 (** Wrapper around Perl [Net::Google::Search] class. *)
2 (* Copyright (C) 2003 Merjis Ltd.
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this library; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
19 $Id: pl_Net_Google_Search.ml,v 1.4 2008-03-01 13:02:21 rich Exp $
24 open Pl_Net_Google_Response
26 let _ = eval "use Net::Google::Search"
28 class net_google_search sv =
33 string_of_sv (call_method sv "key" [])
35 call_method_void sv "key" [sv_of_string v]
37 string_of_sv (call_method sv "query" [])
39 call_method_void sv "query" [sv_of_string v]
41 int_of_sv (call_method sv "starts_at" [])
42 method set_starts_at v =
43 call_method_void sv "starts_at" [sv_of_int v]
45 int_of_sv (call_method sv "max_results" [])
46 method set_max_results v =
47 call_method_void sv "max_results" [sv_of_int v]
48 method restrict types =
49 string_of_sv (call_method sv "restrict" (List.map sv_of_string types))
51 bool_of_sv (call_method sv "filter" [])
53 call_method_void sv "filter" [sv_of_bool v]
55 bool_of_sv (call_method sv "safe" [])
57 call_method_void sv "safe" [sv_of_bool v]
59 string_of_sv (call_method sv "lr" (List.map sv_of_string langs))
61 string_of_sv (call_method sv "ie" (List.map sv_of_string encs))
63 string_of_sv (call_method sv "oe" (List.map sv_of_string encs))
64 method return_estimatedTotal =
65 bool_of_sv (call_method sv "return_estimatedTotal" [])
66 method set_return_estimatedTotal v =
67 call_method_void sv "return_estimatedTotal" [sv_of_bool v]
69 let sv = call_method sv "response" [] in
70 let av = deref_array sv in
71 av_map (fun sv -> new net_google_response sv) av
73 let sv = call_method sv "results" [] in
74 let av = deref_array sv in
75 av_map (fun sv -> new net_google_response sv) av