Fra*_*sKR 5 python soap web-services suds
我正在尝试编写一个 Python 脚本,用于从 ISI Web of Science 中检索有关出版物的信息。我在 GitHub 上找到了 domoritz 的 python 脚本wos.py。它使用 Suds 连接到 ISI Web of Science Web 服务。我已经将它导入到我的 python 脚本中,并按照评论中的非常简短的说明尝试了这段代码:
from wos import *
soap = WokmwsSoapClient()
results = soap.search('Hallam')
Run Code Online (Sandbox Code Playgroud)
然后我收到一个错误:
suds.WebFault: Server raised fault: 'line 1:1: unexpected token: Hallam'
Run Code Online (Sandbox Code Playgroud)
我查看了 wos.py 中的代码。这是search函数:
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)
Run Code Online (Sandbox Code Playgroud)
我想也许query不能只是一个普通的 python 字符串,正如我在WSDL页面中看到的,userQuery实际上是 type xs:string。但是这个页面说userQuery“必须是一个有效的 WOKQL 查询语句。这个要求是内部强制执行的”,这使得我似乎不必传入特殊类型。无论如何,我尝试附加'xs:string'到查询的开头,但我遇到了同样的错误。
有人知道使用这种方法的正确方法吗?
显然传入一个 python 字符串很好,但我需要一个更像搜索查询的字符串。我在之前提到的网站上找到了这个例子:
<soap:Body>
<woksearch:search xmlns:woksearch="http://woksearch.v3.wokmws.thomsonreuters.com">
<!-- this request has the minimum required elements,
but contains all valid retrieve options
for this operation and databaseId -->
<queryParameters>
<databaseId>WOK</databaseId>
<userQuery>AU=Arce, G*</userQuery>
<queryLanguage>en</queryLanguage>
</queryParameters>
....
Run Code Online (Sandbox Code Playgroud)
所以我尝试使用results = soap.search('AU=Hallam')并且有效。我现在可以做类似的事情print results.recordsFound并且得到正确的答案。