You can hit the API yourself, but the documentation is hard to read, I haven't written what parameters are needed in the request after all, and I have to add my own hashed Sigunature to the URL. It's a hassle without it, so use a convenient library.
python-amazon-simple-product-api
It's super convenient. You can find out the installation etc. immediately by reading the README.
When I actually run it, it looks like this.
If you do not specify the region, you may be searching overseas stores, or you will not be able to find the product, so be sure to remember region =" JP "
.
In [9]: amazon = AmazonAPI(ACCESS_KEY, SECRET_KEY, ASSOCIATE_ID, region="JP")
In [10]: product = amazon.lookup(ItemId='B00E7N623K')
In [11]: product.__dict__
Out[11]:
{'api': <amazon.api.AmazonAPI at 0x1037e9cf8>,
'aws_associate_tag': 'Associate ID',
'parent': None,
'parsed_response': <Element {http://webservices.amazon.com/AWSECommerceService/2013-08-01}Item at 0x1035b9e08>,
'region': 'JP'}
In [12]: product.parsed_response
Out[12]: <Element {http://webservices.amazon.com/AWSECommerceService/2013-08-01}Item at 0x1035b9e08>
In [13]: product.parsed_response.ItemAttributes
Out[13]: <Element {http://webservices.amazon.com/AWSECommerceService/2013-08-01}ItemAttributes at 0x10382e508>
In the contents of the library, I feel that lxml is parsing the xml response. In fact, even in the above execution example, the Element instance of lxml is nested and included.
I've read the official API documentation for a long time, but obviously this is easier.
Recommended Posts