当前位置: 首页>>代码示例>>Python>>正文


Python SOAPProxy.doGoogleSearch方法代码示例

本文整理汇总了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
开发者ID:jhkoivis,项目名称:dvelib,代码行数:37,代码来源:Spider.py

示例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)
开发者ID:martofrog,项目名称:pdftoref,代码行数:64,代码来源:Spider.py


注:本文中的SOAPpy.SOAPProxy.doGoogleSearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。