如何解析保存在txt中的suds对象?

时间:2017-11-28 20:27:20

标签: python json xml soap suds

我正在使用与肥皂水有效的Web of Science Python client,我几乎找不到任何有用的文档。我已经下载了超过18k的搜索结果(由于API的限制需要几个小时)并保存到文本文件中。现在我想解析它们。

要解析的示例文件:

(searchResults){
   queryId = "462"
   recordsFound = 1
   recordsSearched = 65470148
   records[] = 
      (liteRecord){
         uid = "WOS:000353665400007"
         title[] = 
            (labelValuesPair){
               label = "Title"
               value[] = 
                  "A New Perspective on Instantiation",
            },
         doctype[] = 
            (labelValuesPair){
               label = "Doctype"
               value[] = 
                  "Article",
            },
         source[] = 
            (labelValuesPair){
               label = "Issue"
               value[] = 
                  "3",
            },
            (labelValuesPair){
               label = "Pages"
               value[] = 
                  "448-463",
            },
            (labelValuesPair){
               label = "Published.BiblioDate"
               value[] = 
                  "WIN",
            },
            (labelValuesPair){
               label = "Published.BiblioYear"
               value[] = 
                  "2015",
            },
            (labelValuesPair){
               label = "SourceTitle"
               value[] = 
                  "LIBRARY TRENDS",
            },
            (labelValuesPair){
               label = "Volume"
               value[] = 
                  "63",
            },
         authors[] = 
            (labelValuesPair){
               label = "Authors"
               value[] = 
                  "Garbacz, Pawel",
            },
         other[] = 
            (labelValuesPair){
               label = "Identifier.Eissn"
               value[] = 
                  "1559-0682",
            },
            (labelValuesPair){
               label = "Identifier.Ids"
               value[] = 
                  "CG9UK",
            },
            (labelValuesPair){
               label = "Identifier.Issn"
               value[] = 
                  "0024-2594",
            },
            (labelValuesPair){
               label = "ResearcherID.Disclaimer"
               value[] = 
                  "ResearcherID data provided by Clarivate Analytics",
            },
      },
 }
  1. 如何将这些文件“重新”解析为python?
  2. 如果这样做很难 - 如何将suds对象保存为XML / JSON?

1 个答案:

答案 0 :(得分:0)

我以另一种方式解决了这个问题。

我刚创建了自己的Web of Science Web服务客户端,可以打印出JSON。您可以在此处找到它:https://github.com/mdziezyc/WoSPythonClient