Get food data using Amazon api (python).
Learn how to use Amazon API to some extent. Reference URL http://www.ajaxtower.jp/ecs/
Add a time stamp to the query. The format is as follows
import time
Time = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
url_qs.append(("Timestamp", [Time]))
url_qs = sorted(url_qs)
First, a hash is generated according to the sha-256 standard using the private key given by amazon.
import hmac, hashlib
hmac_digest = hmac.new(array['secret_key'], req, hashlib.sha256).digest()
Encode the generated hash into base64 and quote to complete the sinature
import base64
base64_encoded = base64.b64encode(hmac_digest) # base64
signature = urllib2.quote(base64_encoded)
from pyquery import PyQuery as pq
from lxml import etree
a = pq(etree.fromstring(test), parser='xml')
f = a('ns|Feature', namespaces={"ns":"http://webservices.amazon.com/AWSECommerceService/2011-08-01"}).text())
Raw materials are stored in Feature
Recommended Posts