Мой код
import json
import requests
request = requests.get('http://example.com/json')
for item in request:
data = request.json()
data = data['items'][0]
price = data['salePrice']
name = data['name']
print(name)
Данные
{"items":[ {
"itemId" : 5969538,
"parentItemId" : 5969538,
"name" : "Breakfast Nook 3 Piece Corner Dining Set, Black",
"salePrice" : 288.99,
"shortDescription" : "Create extra space and a cozy area to dine and relax with this stylish nook corner dining set. A rich black finish adds sophistication to any dining area, while the corner seats and additional bench provide comfortable seating for up to five people. Coordinate with your decor by adding colorful seating pads or pillows.<br><br><b>Product Details:</b><ul><li>Four piece set</li><li>Constructed of durable MDF</li><li>Rich, black finish</li><li>Includes two corner / wall nooks with seating, one table and one bench</li><li>Assembly required</li><li><b>Please note that all pieces are shipped separately.</b></li></ul>",
"longDescription" : "<br><ul><li style="list-style: none"><b>Product Details:</b></li><li>Four piece set</li><li>Constructed of durable MDF</li><li>Rich, black finish</li><li>Includes two corner / wall nooks with seating, one table and one bench</li><li>Assembly required</li><li>Please do not use power tool for assembly</li><li><b>Please note that all pieces are shipped separately.</b></li><li>Dimensions for the Dining Set:</li><li>Longer Nook side - 63 1/2 x 20 x 34"H</li><li>Shorter Nook side - 48 x 20 x 34"H</li><li>Nook Table - 43 x 27 1/2 x 29"H</li><li>Nook Bench - 40 x 12 x 18"H</li></ul>",
"thumbnailImage" : "
","mediumImage" : "
","largeImage" : "
","productTrackingUrl" : "http://linksynergy.walmart.com/fs-bin/c ... rc%253Dapi",
"ninetySevenCentShipping" : false,
"color" : "Black",
"marketplace" : false,
"shipToStore" : false,
"freeShipToStore" : false,
"productUrl" : "http://c.affil.walmart.com/t/api00rb?l= ... eadonlyapi",
"customerRating" : "2.88",
"numReviews" : 1,
"customerRatingImage" : "http://i2.walmartimages.com/i/CustRating/2_9.gif",
"rollBack" : true,
"bundle" : true,
"clearance" : false,
"stock" : "Not available",
"addToCartUrl" : "http://c.affil.walmart.com/t/api00rb?l= ... eadonlyapi",
"affiliateAddToCartUrl" : "http://linksynergy.walmart.com/fs-bin/c ... rc%253Dapi",
"freeShippingOver50Dollars" : true,
"availableOnline" : false
}, {
"itemId" : 12321374,
"parentItemId" : 12321374,
"name" : "Castle Tent Loft Bed w/ Slide ; Under Bed Storage, Blue",
"salePrice" : 369.01,
"shortDescription" : "Finished in White powder coat with Blue and Red Microfiber fabric tent",
"longDescription" : "Fun Castle Tent Bunk Bed with Slide includes a tent over twin bed and a covered hiding place below. The covered hiding place below can also be used as under bed storage. The top of the slide is tented with a tower with peek through, fold down window covers. <ul class="noindent"><li>Finished in White powder coat with Blue and Red Microfiber fabric tent, 100% polyester.</li><li>Uses a standard twin size mattress (sold separately).</li><li>Only use a twin size mattress that is 74-75" long and 37.5-38.5" wide.</li><li>Bunk bed is tested and certified by an independent testing laboratory to meet all minimum requirements of ASTM F1427-07 and U.S. CFR 1213 and 1513.</li><li>Some assembly required. 79-3/4" x 101-1/4" x 92" tall.</li></ul>",
"brandName" : "Castle",
"thumbnailImage" : "
","mediumImage" : "
","largeImage" : "
","productTrackingUrl" : "http://linksynergy.walmart.com/fs-bin/c ... rc%253Dapi",
"ninetySevenCentShipping" : false,
"size" : "Twin",
"color" : "Blue",
"marketplace" : false,
"shipToStore" : false,
"freeShipToStore" : false,
"productUrl" : "http://c.affil.walmart.com/t/api00rb?l= ... eadonlyapi",
"customerRating" : "4.574",
"numReviews" : 54,
"customerRatingImage" : "http://i2.walmartimages.com/i/CustRating/4_6.gif",
"rollBack" : true,
"bundle" : true,
"clearance" : false,
"stock" : "Not available",
"gender" : "Boys",
"addToCartUrl" : "http://c.affil.walmart.com/t/api00rb?l= ... eadonlyapi",
"affiliateAddToCartUrl" : "http://linksynergy.walmart.com/fs-bin/c ... rc%253Dapi",
"freeShippingOver50Dollars" : true,
"availableOnline" : false
}, {
"itemId" : 13241485,
"parentItemId" : 13241485,
"name" : "Extra Large Kitchen Cart, Black with Wood Top",
"salePrice" : 235.0,
"shortDescription" : "Add extra workspace and storage in your kitchen with this large kitchen cart. It features a natural wood top, two spacious drawers and a three-door storage cabinet with adjustable shelf.<br><br>This item ships in two separate boxes and may not arrive at the same time.",
"longDescription" : "<br><ul><li>Large kitchen cart</li><li>Constructed of rubber wood, MDF and particle board</li><li>Natural wood top with black finish</li><li>2 utility drawers</li><li>3-door storage cabinet with adjustable shelf</li><li>Towel holder on side</li><li>Casters for mobility</li><li>Measures: 48''L x 18''W x 36''H</li><li>Model# 60048BLK</li></ul><br><b>Please note: This item ships in 2 boxes and each piece may arrive separately.</b>",
"thumbnailImage" : "
","mediumImage" : "
","largeImage" : "
","productTrackingUrl" : "http://linksynergy.walmart.com/fs-bin/c ... rc%253Dapi",
"ninetySevenCentShipping" : false,
Подробнее здесь: https://stackoverflow.com/questions/367 ... n-for-loop