あなたのリクエストに 'Images'レスポンスグループを含める必要があります。
XMLのImageSetsのリストは、その後、画像のプロパティを介してアクセスすることができるが、XMLパーサーを使用して解析する必要があります。
product.images
PythonでXMLを解析については、こちらの記事をチェックしてみて下さい: How do I parse XML in Python?
リファレンス:ライブラリのソースコードからhttps://docs.aws.amazon.com/AWSECommerceService/latest/DG/RG_Images.html
:
@property
def images(self):
"""List of images for a response.
When using lookup with RespnoseGroup 'Images', you'll get a
list of images. Parse them so they are returned in an easily
used list format.
:return:
A list of `ObjectifiedElement` images
"""
try:
images = [image for image in self._safe_get_element(
'ImageSets.ImageSet')]
except TypeError: # No images in this ResponseGroup
images = []
return images
画像セットXMLは次のようになります。
<ImageSets>
<ImageSet Category="primary">
<SwatchImage>
<URL>https://ecx.images-amazon.com/images/I/51YL4rlI%2B9L._SL30_.jpg</URL>
<Height Units="pixels">30</Height>
<Width Units="pixels">23</Width>
</SwatchImage>
<SmallImage>
<URL>https://ecx.images-amazon.com/images/I/51YL4rlI%2B9L._SL75_.jpg</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">58</Width>
</SmallImage>
<ThumbnailImage>
<URL>https://ecx.images-amazon.com/images/I/51YL4rlI%2B9L._SL75_.jpg</URL>
<Height Units="pixels">75</Height>
<Width Units="pixels">58</Width>
</ThumbnailImage>
<TinyImage>
<URL>https://ecx.images-amazon.com/images/I/51YL4rlI%2B9L._SL110_.jpg</URL>
<Height Units="pixels">110</Height>
<Width Units="pixels">86</Width>
</TinyImage>
<MediumImage>
<URL>https://ecx.images-amazon.com/images/I/51YL4rlI%2B9L._SL160_.jpg</URL>
<Height Units="pixels">160</Height>
<Width Units="pixels">124</Width>
</MediumImage>
<LargeImage>
<URL>https://ecx.images-amazon.com/images/I/51YL4rlI%2B9L.jpg</URL>
<Height Units="pixels">500</Height>
<Width Units="pixels">389</Width>
</LargeImage>
</ImageSet>
</ImageSets>
ありがとう、それも試しましたが、まだ問題があります。 イメージURLを取得する代わりに、何らかのリファレンスを取得しますか? '[、] ' –
KatharsisHerbie
ソースを見ると、すべてのイメージURLのリストを返すプロパティ@imagesがあります。次のものでアクセスできるはずです:' product.images' – zachdb86
私は何かが欠けていると思います... それは私のコード: 'product = amazon.lookup(ItemId = 'B003P0ZB1K'、ResponseGroup = 'Images') print(product.images)'です。 それは私の最後のコメント...投稿した正確な参照テキストを私に印刷します。 – KatharsisHerbie