Esempio n. 1
0
 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'
Esempio n. 2
0
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
Esempio n. 3
0
def citingArticles(UID, SID):
    url = client = {}
    start_time = time.time()

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

    databaseId = "WOS"
    uid = UID
    queryLanguage = "en"
    editions = None
    timeSpan = {'begin': "2003-01-01",
                'end': "2017-12-31"}

    rparams = {'count': 100,
               'firstRecord': 1,
               'viewField': {'collectionName': 'WOS',
                             'fieldName': ['pub_info', 'titles']}}

    check_time(start_time)

    return client['citingArticles'].service.citingArticles(databaseId, uid, editions, timeSpan, queryLanguage, rparams)
Esempio n. 4
0
 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)
Esempio n. 5
0
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."
Esempio n. 6
0
 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)
Esempio n. 7
0
 def conectar(self):
     url = 'http://ws01.reclameaqui.com.br/webservice.php?wsdl'
     t = HttpTransport()
     proxy = urllib2.ProxyHandler({'http': 'http://5.9.41.147:6680'})
     opener = urllib2.build_opener(proxy)
     t.urlopener = opener
     self.client = Client(
         url, transport=t, username=self.username, password=self.password)
Esempio n. 8
0
def citedReferencesRetrieve(queryId, SID, start_count):
    url = client = {}
    start_time = time.time()

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

    rparams = {'count': 100,
               'firstRecord': start_count}

    check_time(start_time)

    return client['citedReferencesRetrieve'].service.citedReferencesRetrieve(queryId, rparams)
Esempio n. 9
0
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)
Esempio n. 10
0
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
Esempio n. 11
0
def retrieveById(UID, SID):
    url = client = {}
    start_time = time.time()

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

    databaseId = "WOS"
    uid = UID
    queryLanguage = "en"

    rparams = {'count': 1,
               'firstRecord': 1}

    check_time(start_time)

    return client['retrieveById'].service.retrieveById(databaseId, uid, queryLanguage, rparams)
Esempio n. 12
0
def retrieveById(UID, SID):
    url = client = {}
    start_time = time.time()

    http = HttpTransport()
    opener = urllib.request.build_opener(HTTPSudsPreprocessor(SID)) #build_opener returns OpenerDirector object
    http.urlopener = opener #hands OpenerDirector object to http
    url['retrieveById'] = 'http://search.webofknowledge.com/esti/wokmws/ws/WokSearch?wsdl'
    client['retrieveById'] = Client(url['retrieveById'], transport=http)

    databaseId = "WOS" # qparams?!
    uid = UID
    queryLanguage = "en"

    rparams = {'count': 1, # retrieve 1 result instead of 100
               'firstRecord': 1}

    check_time(start_time) #where does this come from?!

    return client['retrieveById'].service.retrieveById(databaseId, uid, queryLanguage, rparams)
Esempio n. 13
0
def search(query, SID):
    url = client = {}
    start_time = time.time()

    http = HttpTransport()
    opener = urllib.request.build_opener(HTTPSudsPreprocessor(SID)) #build_opener returns an OpenerDirector instance
    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'} # parameters of our query. there are optional parameters such as time etc

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

    check_time(start_time)

    return client['search'].service.search(qparams, rparams) # constructs query and returns list ish thing with id as first element, result, etc.
Esempio n. 14
0
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)
Esempio n. 15
0
def retrieve(queryId, SID, start_count, namespace):
    url = client = {}
    start_time = time.time()

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

    if namespace == "FullRecord":
        rparams = {'count': 100,
                   'firstRecord': start_count}

    else:
        rparams = {'count': 100,
                   'firstRecord': start_count,
                   'viewField': {'collectionName': 'WOS',
                                 'fieldName': ['pub_info', 'titles']}}

    check_time(start_time)

    return client['retrieve'].service.retrieve(queryId, rparams)
Esempio n. 16
0
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
Esempio n. 17
0
    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
Esempio n. 18
0
 def initSearchClient(self):
     http = HttpTransport()
     opener = urllib2.build_opener(HTTPSudsPreprocessor(self.SID))
     http.urlopener = opener
     self.client['search'] = Client(self.url['search'], transport = http)
Esempio n. 19
0
 def initSearchClient(self):
     http = HttpTransport()
     opener = urllib2.build_opener(HTTPSudsPreprocessor(self.SID))
     http.urlopener = opener
     self.client['search'] = Client(self.url['search'], transport=http)