Help Me Get started please

324 views
Skip to first unread message

Wrayman

unread,
Oct 29, 2016, 7:41:44 PM10/29/16
to Octopart API
This is the sample script from Octo

I can't get past how to print out each individual item in the JSON

For example,I want to see the Prices and everytime I try to branch I get errors if I try this print (item['offers']['prices']), it doesn't work

import json
import urllib2

url += '&queries=[{"mpn":"0190430010"}]'
url += '&apikey=xxxxxxxxx'

data = urllib2.urlopen(url).read()
response = json.loads(data)

# print request time (in milliseconds)
print (response['msec'])

# print mpn's
for result in response['results']:
for item in result['items']:
for price in result ['PartOffer']:
        print (item['mpn'], price['prices'])
Reply all
Reply to author
Forward
0 new messages