Skip to content

Instantly share code, notes, and snippets.

@domoritz
Forked from pol/wos.php
Created March 10, 2012 19:32
Show Gist options
  • Save domoritz/2012629 to your computer and use it in GitHub Desktop.
Save domoritz/2012629 to your computer and use it in GitHub Desktop.
Web of Science API access with ruby, python and php libs
<?php
$auth_url = "http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl";
$auth_client = @new SoapClient($auth_url);
$auth_response = $auth_client->authenticate();
$search_url = "http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite?wsdl";
$search_client = @new SoapClient($search_url);
$search_client->__setCookie('SID',$auth_response->return);
$search_array = array(
'queryParameters' => array(
'databaseID' => 'WOS',
'userQuery' => 'AU=Douglas T*',
'editions' => array(
array('collection' => 'WOS', 'edition' => 'SSCI'),
array('collection' => 'WOS', 'edition' => 'SCI')
),
'queryLanguage' => 'en'
),
'retrieveParameters' => array(
'count' => '5',
'fields' => array(
array('name' => 'Date', 'sort' => 'D')
),
'firstRecord' => '1'
)
);
try{
$search_response = $search_client->search($search_array);
} catch (Exception $e) {
echo $e->getMessage();
}
print_r($search_response);
?>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from suds.client import Client
from suds.transport.http import HttpTransport
import urllib2
class HTTPSudsPreprocessor(urllib2.BaseHandler):
def __init__(self, SID):
self.SID = SID
def http_request(self, req):
req.add_header('cookie', 'SID="'+self.SID+'"')
return req
https_request = http_request
class WokmwsSoapClient():
"""
main steps you have to do:
soap = WokmwsSoapClient()
results = soap.search(...)
"""
def __init__(self):
self.url = self.client = {}
self.SID = ''
self.url['auth'] = 'http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl'
self.url['search'] = 'http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite?wsdl'
self.prepare()
def __del__(self):
self.close()
def prepare(self):
"""does all the initialization we need for a request"""
self.initAuthClient()
self.authenticate()
self.initSearchClient()
def initAuthClient(self):
self.client['auth'] = Client(self.url['auth'])
def initSearchClient(self):
http = HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor(self.SID))
http.urlopener = opener
self.client['search'] = Client(self.url['search'], transport = http)
def authenticate(self):
self.SID = self.client['auth'].service.authenticate()
def close(self):
self.client['auth'].service.closeSession()
def search(self, query):
qparams = {
'databaseID' : 'WOS',
'userQuery' : query,
'queryLanguage' : 'en',
'editions' : [{
'collection' : 'WOS',
'edition' : 'SCI',
},{
'collection' : 'WOS',
'edition' : 'SSCI',
}]
}
rparams = {
'count' : 5, # 1-100
'firstRecord' : 1,
'fields' : [{
'name' : 'Relevance',
'sort' : 'D',
}],
}
return self.client['search'].service.search(qparams, rparams)
require 'savon'
require 'handsoap'
require 'pp'
class Soapy
def initialize(opts)
@client = Savon::Client
@auth_url = opts[:auth_url] ||
"http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl"
@search_url = opts[:search_url] ||
"http://search.isiknowledge.com/esti/wokmws/ws/WokSearchLite?wsdl"
@search_xml = opts[:search_xml] ||
<<-EOF
<queryParameters>
<databaseID>WOS</databaseID>
<userQuery>AU=Douglas T*</userQuery>
<editions>
<collection>WOS</collection>
<edition>SSCI</edition>
</editions>
<editions>
<collection>WOS</collection>
<edition>SCI</edition>
</editions>
<queryLanguage>en</queryLanguage>
</queryParameters>
<retrieveParameters>
<count>5</count>
<fields>
<name>Date</name>
<sort>D</sort>
</fields>
<firstRecord>1</firstRecord>
</retrieveParameters>
EOF
end
def authenticate(auth_url=@auth_url)
@auth_client ||= @client.new(@auth_url)
@auth_client.request :authenticate
@session_cookie = @auth_client.http.headers["Cookie"]
@search_client.http.headers["Cookie"] = @session_cookie if @search_client
end
def search(query=@search_xml)
@search_client ||= @client.new(@search_url)
authenticate if @session_cookie.nil?
@last_search = @search_client.request(:search) { soap.body = query}
end
def destroy
@auth_client.request :close_session
end
end
# Savon
soap = Soapy.new
pp soap.search
# Handsoap
# So... the Handsoap API turned out to be a pain, so let's just use Savon.
@FrancesKR
Copy link

Hi,

I'm trying to use your wos.py script to access information about a bunch of publications. Basically I have a list of authors, and I want to get all the publications for each of them, then get all of the other authors for each of those publications. I can't figure out from the Web of Knowledge web service API how to access information from the search results. So far, I've just managed to get results.recordsFound. Do you know how I can access the authors for each record, or change your search function to make sure this information is returned?

Any help is appreciated! Thanks for writing this script,

Frances

@arogozin
Copy link

Frances Russell,

In past 4 months I have extensively worked with WOS API. Please contact me at arogozin@nyu.edu if you'd like any help.

Regards,
Aleksandr Rogozin

@jkitchin
Copy link

jkitchin commented Jun 8, 2015

FYI, running the python version of this gives this error:
The Web Service (version 2.0) has been retired permanently.

@dannylessio
Copy link

Also running wos.php i retrieve the same error:

"The Web Service (version 2.0) has been retired permanently. Please contact Thomson Reuters IP and Science Technical Support http://ip-science.thomsonreuters.com/techsupport/ for information on how to obtain a new version of our Web Service."

Is there a new version? Does anyone knows something?
Thanks.

@bdulac
Copy link

bdulac commented Feb 2, 2016

@karlek
Copy link

karlek commented Feb 8, 2016

I'm trying to get use version 3.0, anyone managed to get it working?

@karlek
Copy link

karlek commented Feb 8, 2016

I got it working! Just change databaseID to databaseId and the new URLs are:
http://search.webofknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl,
http://search.webofknowledge.com/esti/wokmws/ws/WokSearch?wsdl.

@enricobacis
Copy link

I created a python client library and cli tool with also authenticated access. You can install it with:

pip install wos

Github repository: https://github.com/enricobacis/wos
PyPI: https://pypi.python.org/pypi/wos

@alexweissman
Copy link

Does anyone know if they provide API keys for institutional users?

@eperez-iaa
Copy link

I need help.
I log into WoS via web interface and institutional access.
I copy the SID that appears in the session and use it with wos command line but it gives me error:

wos -s Z2I5xJejzCTcVtrz2lH doi '10.1007/s00283-010-9170-7'

ERROR: (SEE0003) There is a problem with your session identifier (SID). Reason: Error received from a server supporting the Web service. Cause: Supporting server error message = [Session not found: SID=Z2I5xJejzCTcVtrz2lH NodeID=W6]. Supporting server error code = [Server.sessionNotFound]. Remedy: If the session identifier is expired or invalid, get a new session identifier and submit your request again. If the session identifier is missing correct your SOAP client. Otherwise call customer support.

I have tried several times with some minor changes and different sessions, but to no avail.
Help would be very much appreciated.

@dazza-codes
Copy link

See also recent work we have done in ruby using the savon gem

@zakcali
Copy link

zakcali commented Nov 21, 2020

Thanks for the examples.
I created a nodejs code, retrieves records pages by page, matches Quartile values with journal issn/eissn codes by using a quartile dictionary created on 2020, then prints them:
https://github.com/zakcali/wos-lite-api-nodejs

@waynewu2019
Copy link

waynewu2019 commented Nov 21, 2020 via email

@zakcali
Copy link

zakcali commented Nov 21, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment