本文整理汇总了Python中SOAPpy.SOAPProxy.doGoogleSearch方法的典型用法代码示例。如果您正苦于以下问题:Python SOAPProxy.doGoogleSearch方法的具体用法?Python SOAPProxy.doGoogleSearch怎么用?Python SOAPProxy.doGoogleSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SOAPpy.SOAPProxy
的用法示例。
在下文中一共展示了SOAPProxy.doGoogleSearch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: googleSearch
# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import doGoogleSearch [as 别名]
def googleSearch(title):
'''
It is the function of the application that make the request at google WS using
getting the first url of response.
@param title: the title of the article to serach for
@return: the first url
'''
_query=title
# create SOAP proxy object
google = SOAPProxy(_url, _namespace)
# call search method over SOAP proxy
results = google.doGoogleSearch( _license_key, _query,
_start, _maxResults,
_filter, _restrict,
_safeSearch, _lang_restrict, '', '' )
# display results
# print 'google search for " ' + _query + ' "\n'
# print 'estimated result count: ' + str(results.estimatedTotalResultsCount)
# print ' search time: ' + str(results.searchTime) + '\n'
# print 'results ' + str(_start + 1) + ' - ' + str(_start + _maxResults) +':\n'
numresults = len(results.resultElements)
if numresults:
url = results.resultElements[0].URL
else:
url= "#"
return url
示例2: googleSearch
# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import doGoogleSearch [as 别名]
def googleSearch(title):
'''
It is the function of the application that make the request at google WS using
getting the first url of response.
@param title: the title of the article to serach for
@return: the first url
'''
# create SOAP proxy object
google = SOAPProxy(_url, _namespace)
_query= google.doSpellingSuggestion( _license_key, title )
if _query == None:
_query=title
# call search method over SOAP proxy
results = google.doGoogleSearch( _license_key, _query,
_start, _maxResults,
_filter, _restrict,
_safeSearch, _lang_restrict, '', '' )
# display results
# print 'google search for " ' + _query + ' "\n'
# print 'estimated result count: ' + str(results.estimatedTotalResultsCount)
# print ' search time: ' + str(results.searchTime) + '\n'
# print 'results ' + str(_start + 1) + ' - ' + str(_start + _maxResults) +':\n'
numresults = len(results.resultElements)
if numresults:
for i in range(numresults):
url = results.resultElements[i].URL
r = re.compile("http://(.*)\.pdf",re.IGNORECASE)
if (r.match(url)):
url = r.match(url).group()
type = "pdf"
return (url,type,_query)
else:
r = re.compile("http://citeseer.ist.psu.edu/")
if(r.match(url)):
type = "citeseer"
return (url,type,_query)
else:
r = re.compile("http://portal.acm.org/")
if(r.match(url)):
type = "acm"
return (url,type,_query)
else:
r = re.compile("http://doi.ieeecomputersociety/")
if(r.match(url)):
type = "doi"
return (url,type,_query)
else:
pass
type = "default"
return (url,type,_query)
else:
url= "#"
type = None
return (url,type,_query)