1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
$NetBSD: patch-aa,v 1.3 2003/12/24 11:44:08 recht Exp $
--- google.py.orig 2003-06-18 11:17:06.000000000 +0200
+++ google.py 2003-12-24 12:38:27.000000000 +0100
@@ -43,7 +43,8 @@
Erik Max Francis, for the command line interface
Michael Twomey, for HTTP proxy support"""
-import SOAP
+from SOAPpy import SOAPProxy
+from SOAPpy import Types
import os, sys, getopt
LICENSE_KEY = None
@@ -53,8 +54,8 @@
class NoLicenseKey(Exception): pass
_url = 'http://api.google.com/search/beta2'
_namespace = 'urn:GoogleSearch'
-_false = SOAP.booleanType(0)
-_true = SOAP.booleanType(1)
+_false = Types.booleanType(0)
+_true = Types.booleanType(1)
_googlefile1 = ".googlekey"
_googlefile2 = "googlekey.txt"
_licenseLocations = (
@@ -201,11 +202,11 @@
class _SearchBase:
def __init__(self, params):
for k, v in params.items():
- if isinstance(v, SOAP.structType):
- v = v._asdict
+ if isinstance(v, Types.structType):
+ v = v._asdict()
try:
- if isinstance(v[0], SOAP.structType):
- v = [node._asdict for node in v]
+ if isinstance(v[0], Types.structType):
+ v = [node._asdict() for node in v]
except:
pass
self.__dict__[str(k)] = v
@@ -303,16 +304,16 @@
See documentation of these individual classes for list of available attributes
"""
http_proxy = getProxy(http_proxy)
- remoteserver = SOAP.SOAPProxy(_url, namespace=_namespace, http_proxy=http_proxy)
+ remoteserver = SOAPProxy(_url, namespace=_namespace, http_proxy=http_proxy)
license_key = getLicense(license_key)
filter = _marshalBoolean(filter)
safeSearch = _marshalBoolean(safeSearch)
data = remoteserver.doGoogleSearch(license_key, q, start, maxResults, filter, restrict,
safeSearch, language, inputencoding, outputencoding)
- metadata = data._asdict
+ metadata = data._asdict()
del metadata["resultElements"]
metadata = SearchResultsMetaData(metadata)
- results = [SearchResult(node._asdict) for node in data.resultElements]
+ results = [SearchResult(node._asdict()) for node in data.resultElements]
return SearchReturnValue(metadata, results)
def doGetCachedPage(url, license_key = None, http_proxy = None):
@@ -330,7 +331,7 @@
Returns: string, text of cached page
"""
http_proxy = getProxy(http_proxy)
- remoteserver = SOAP.SOAPProxy(_url, namespace=_namespace, http_proxy=http_proxy)
+ remoteserver = SOAPProxy(_url, namespace=_namespace, http_proxy=http_proxy)
license_key = getLicense(license_key)
return remoteserver.doGetCachedPage(license_key, url)
@@ -348,7 +349,7 @@
Returns: text of suggested replacement, or None
"""
http_proxy = getProxy(http_proxy)
- remoteserver = SOAP.SOAPProxy(_url, namespace=_namespace, http_proxy=http_proxy)
+ remoteserver = SOAPProxy(_url, namespace=_namespace, http_proxy=http_proxy)
license_key = getLicense(license_key)
return remoteserver.doSpellingSuggestion(license_key, phrase)
|