返回XML从博托电话 [英] Return XML from boto calls

查看:149
本文介绍了返回XML从博托电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用博托2.32.1 与Python 2.7.6。我有问题的<一个href="http://boto.readthedocs.org/en/latest/ref/mws.html#boto.mws.connection.MWSConnection.list_orders">list_orders中宝途的MWS模块函数来得到我的亚马逊订单XML数据。

I am using boto 2.32.1 with Python 2.7.6. I am having problems with the list_orders function of boto's mws modules to get the XML data of my Amazon orders.

下面是调用我做:

response = connection.list_orders(CreatedAfter='2014-08-26T05:53:44+00:00', 
   MarketplaceId=['XXXXXXXXXXXXX'])

下面是响应的值(有明显的删除个人信息后)

Here is the value of response (with personal information removed obviously)

ListOrdersResponse{u'xmlns': u'https://mws.amazonservices.com/Orders/2013-09-01'}
(ListOrdersResult: ListOrdersResult{}
(CreatedBefore: u'2014-08-26T10:06:10Z', Orders: ^Orders^{}
(Order: [Order{}(***ORDER INFORMATION***)])), 
ResponseMetadata: ^ResponseMetadata^{}(RequestId: u'xxxxxxxxxx'))

这是不理想的,因为我有与ebaysdk,蟒蛇返回的XML工作的另一个模块对eBay销售。亚马逊格式的XML类似于eBay的,所以如果我能得到返回的XML,而不是格式亚马逊以上,这将是辉煌的。

This isn't ideal because I have another module for eBay sales that works with the XML returned by ebaysdk-python. Amazon formats their XML similarly to eBay so if I could get the XML returned by Amazon instead of the format above, it would be brilliant.

我注意到,如果我使用 boto.set_stream_logger('博托'),它将打印返回的XML,所以也许我可以利用这一点不知?

I have noticed that if I use boto.set_stream_logger('boto'), it will print the XML returned so maybe I could take advantage of that somehow?

这是什么,我想退货:

<ListOrdersResponse xmlns="https://mws.amazonservices.com/Orders/2013-09-01">
  <ListOrdersResult>
    <Orders>
      <Order>
        ***ORDER INFORMATION***
      </Order>
    </Orders>
    <CreatedBefore>2014-08-26T10:18:59Z</CreatedBefore>
  </ListOrdersResult>
  <ResponseMetadata>
    <RequestId>XXXXXXXXXXXXXXXXXXXXXXXXXXXXX</RequestId>
  </ResponseMetadata>
</ListOrdersResponse>

然后,我可以使用Python的辉煌位置为xml.etree.ElementTree来分析和处理数据的工作。

I could then use Python's brilliant xml.etree.ElementTree to parse and work with the data.

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

如果我做错了什么,这是我第一次发帖对不起。

Sorry if I done something wrong, it's my first time posting.

推荐答案

我不认为有官方支持的方法,要做到这一点,但你可以做到这一点,以获得原始XML响应返回轻松:

I don't think there's an officially supported method to do this, but you can do this to get the raw XML response back easily:

# Set up
from boto.mws.connection import MWSConnection
MWSConnection._parse_response = lambda s, x, y, z: z

# Usage
result = az.get_matching_product_for_id(MarketplaceId="ATVPDKIKX0DER",
                                            SearchIndex="Books",
                                            IdType="ASIN",
                                            IdList=[0439023521])
# <?xml version="1.0"?>\n<GetMatchingProductForIdResponse xmlns...

这篇关于返回XML从博托电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆