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


Python HttpTransport.urlopener方法代码示例

本文整理汇总了Python中suds.transport.http.HttpTransport.urlopener方法的典型用法代码示例。如果您正苦于以下问题:Python HttpTransport.urlopener方法的具体用法?Python HttpTransport.urlopener怎么用?Python HttpTransport.urlopener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在suds.transport.http.HttpTransport的用法示例。


在下文中一共展示了HttpTransport.urlopener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_sid

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
 def _add_sid(self):
     """Create URL opener with authentication token as header."""
     opener = urllib2.build_opener()
     opener.addheaders = [('Cookie', 'SID="'+self.sid_token+'"')]
     http = HttpTransport()
     http.urlopener = opener
     self._establish_search_client(http)
开发者ID:MSU-Libraries,项目名称:wos,代码行数:9,代码来源:wos.py

示例2: auth

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
def auth(ver, type, username, password):

    if ver == 2:
        if type == 'up':
            auth_client = Client(AUTH_URL_ver2, username = username, password = password) #version 2.0
            SID = auth_client.service.authenticate()
            return SID
        elif type == 'ip':
            auth_client = Client(AUTH_URL_ver2)
            SID = auth_client.service.authenticate()
            return SID
        else:
            print "Type either 'ip' or 'up'. 'ip' for ip access, 'up' for username/password access"
    elif ver == 3:
        if type == 'up':
            username_password = ['username_password'][username]
                #Your username/password from a purchased subscription should go here!
            auth = HttpTransport()
            auth_sender = urllib2.build_opener(HTTPAuthSender(username_password))
            auth.urlopener = auth_sender
            auth_client = Client(AUTH_URL_ver3, transport = auth)
            SID = auth_client.service.authenticate()
            return SID
        elif type == 'ip':
            auth_client = Client(AUTH_URL_ver3) #comment out if using username, password. #version 3.0
            SID = auth_client.service.authenticate()
            return SID
        else:
            print "Type either 'ip' or 'up'. 'ip' for ip access, 'up' for username/password access. username is an integer, password can be a null value for version 3."
    else:
        print "Authentication failed. Invalid version. Your request was not supported by this authentication module."
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:33,代码来源:auth.py

示例3: initSearchClient

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
 def initSearchClient(self):
     print 'initialize search....'
     http = HttpTransport()
     opener = urllib2.build_opener(HTTPSudsPreprocessor(self.SID))
     http.urlopener = opener
     self.client['search'] = Client(self.url['search'], transport = http)
     print 'searching initializtion done'
开发者ID:cadop,项目名称:pyWOS,代码行数:9,代码来源:DownloadData.py

示例4: search_lite

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
def search_lite(fieldtag, searchterm, ver, count, SID):
    #fieldtag must be 'PN = ' or 'CD ='
    http = HttpTransport()
    opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
    http.urlopener = opener
    client_obj = Client(SEARCH_LITE_URL[int(ver - 2)], transport = http, retxml = True)

    query = fieldtag + '=' + searchterm
    #construct query and retrieve field parameters
    qparams = {
                'databaseId' : 'DIIDW',
                'userQuery' : query,
                'queryLanguage' : 'en',
                'editions' : [{
                            'collection' : 'DIIDW',
                            'edition' : 'CDerwent',
                            },{
                            'collection' : 'DIIDW',
                            'edition' : 'MDerwent',
                            },{
                            'collection' : 'DIIDW',
                            'edition' : 'EDerwent',
                            }]
                }
    rparams = {
                'count' : count, # 1-500
                'firstRecord' : 1,
                'sortField' : [{
                            'name' : 'TC',
                            'sort' : 'D',
                            }]
                }
    result = client_obj.service.search(qparams, rparams)
    return result
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:36,代码来源:search.py

示例5: search

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
def search(fieldtag, searchterm, ver, count, SID):
    '''
    Makes a search query to the database.
    :param fieldtag: fieldtag must be 'PN = ' or 'CD ='
    :param searchterm: search term. in this case, the patent number.
    :param ver: version 2 or 3. refer to the thomson reuters documentation.
    :param count: requested retrieval count.
    :param SID: Session ID.
    :return: output xml.
    '''

    http = HttpTransport()
    opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
    http.urlopener = opener
    client_obj = Client(SEARCH_URL[int(ver - 2)], transport = http, retxml = True)

    query = fieldtag + '=' + searchterm
    #construct query and retrieve field parameters
    qparams = {
                'databaseId' : 'DIIDW',
                'userQuery' : query,
                'queryLanguage' : 'en',
                'editions' : [{
                            'collection' : 'DIIDW',
                            'edition' : 'CDerwent',
                            },{
                            'collection' : 'DIIDW',
                            'edition' : 'MDerwent',
                            },{
                            'collection' : 'DIIDW',
                            'edition' : 'EDerwent',
                            }]
                }
    rparams = {
                'count' : count, # 1-500
                'firstRecord' : 1,
                'sortField' : [{
                            'name' : 'Relevance',
                            'sort' : 'D',
                            }]
                }
    result = client_obj.service.search(qparams, rparams)
    return result
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:45,代码来源:search.py

示例6: search

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
def search(query, SID):
    url = client = {}

    http = HttpTransport()
    opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
    http.urlopener = opener
    url['search'] = 'http://search.webofknowledge.com/esti/wokmws/ws/WokSearch?wsdl'
    client['search'] = Client(url['search'], transport = http)

    qparams = {
                'databaseId' : 'WOS',
                'userQuery' : query,
                'queryLanguage' : 'en'
            }

    rparams = {
                'count' : 100, # 1-100
                'firstRecord' : 1
            }

    return client['search'].service.search(qparams, rparams)
开发者ID:apgoldst,项目名称:wok_search,代码行数:23,代码来源:wok_soap_2.py

示例7: retrieve_by_id_lite

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
def retrieve_by_id_lite(input_term, ver, start_record, max_count, SID):
    '''
    This is a method used for lite services.
    :param input_term: input search term.
    :param ver: Version 2 or 3. Refer to Thomson Reuters Documentation for details.
    :param start_record: starting record point
    :param max_count: maximum request count
    :param SID: Session ID.
    :return: output xml
    '''
    http = HttpTransport()
    opener = urllib2.build_opener(HTTPSudsPreprocessor(SID))
    http.urlopener = opener
    client_obj = Client(SEARCH_LITE_URL[int(ver - 2)], transport = http, retxml = True)
    rparams = {
                'count' : max_count, # 1-100
                'firstRecord' : start_record,
                'sortField' : [{
                            'name' : 'Relevance',
                            'sort' : 'D',
                            }]
                }
    cited_results = client_obj.service.retrieveById('DIIDW', input_term, 'en', rparams)
    return cited_results
开发者ID:ahdoki,项目名称:tasters-choice,代码行数:26,代码来源:retrieveById.py

示例8: __init__

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
    def __init__(self,options,config_file=None,session="DWE"):
        """Datastream SOAP Client

        >>> ds=Datastream()
        """

        _set_debug(logging.WARN,
                   'suds.resolver',
                   'suds.metrics',
                   'suds.xsd.sxbasic',
                   'suds.xsd.query',
                   'suds.client',
                   'suds.wsdl',
                   'suds.transport.http',
                   'suds.mx.core',
                   'suds.umx.typed',
                   'suds.xsd.schema',
                   'suds.xsd.sxbase',
                   'suds.mx.literal')

        if config_file is None:
            if exists(expanduser('~/.dwe.conf')):
                config_file = expanduser('~/.dwe.conf')
                os.chmod(config_file,stat.S_IRUSR | stat.S_IWUSR)
            else:
                config_file = DEFAULT_DSTREAM_CONF_FILE

        config_file = expanduser(expandvars(config_file))

        self._options = options

        if not exists(config_file):
            LOGGER.info('no configuration for datastream (%s). using BITS path',config_file)
            config_file = join(BITS_ETC,DEFAULT_BITS_CONF_FILE)

        self.config_file = config_file

        if not exists(self.config_file):
            raise IOError, 'Datastream Configuration File not Found %s' % config_file

        
        dstream_info = get_session(config_file,session,
                                   secure=True,
                                   url='http://dataworks.thomson.com/dataworks/enterprise/1.0/webServiceClient.asmx?WSDL',
                                   user=(None,ValueError),
                                   password=(None,ValueError),
                                   realm=''
                                   )
        self._auth=dstream_info

        t = HttpTransport()


        ### Proxy if any
        #
        proxy_info = get_proxy()        
        if proxy_info:
            pip={
                'http':proxy_info['proxy'],
                'https':proxy_info['proxy'],
                }
            proxy = urllib2.ProxyHandler(pip)
            # opener = urllib2.build_opener(SocksiPyHandler(socks.PROXY_TYPE_SOCKS4, 'localhost', 8080))
            opener = urllib2.build_opener(proxy)
            urllib2.install_opener(opener)
            t.urlopener = opener
            LOGGER.debug('proxy info for http: %s',pip['http'])
        #
        #
        ###
        try:
            Client.__init__(self,self._auth['url'],transport=t)
        except urllib2.URLError, exc:
            LOGGER.error('{}: No connection to {}'.format(self._options.job,self._auth['url']))
            raise exc
开发者ID:exedre,项目名称:e4t.new,代码行数:77,代码来源:DatastreamProvider.py

示例9: initSearchClient

# 需要导入模块: from suds.transport.http import HttpTransport [as 别名]
# 或者: from suds.transport.http.HttpTransport import urlopener [as 别名]
 def initSearchClient(self):
     http = HttpTransport()
     opener = urllib2.build_opener(HTTPSudsPreprocessor(self.SID))
     http.urlopener = opener
     self.client['search'] = Client(self.url['search'], transport = http)
开发者ID:apgoldst,项目名称:wok_search,代码行数:7,代码来源:wok_soap.py


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