r3 = requests.get('www.website.com/api', params=headers)
struct = r3.json()
for k,v in struct.items():
print (str(k) + str(v))
output :
FoundCategories[]
PageSize1
Page1
List[{'ExteriorColour': None, 'CategoryPath': '/Trade-Me-Motors/Cars/Bentley', 'Subtitle': 'sdf', 'BestContactTime': None, 'StartPrice': 100.0, 'Doors': 0, 'Fuel': None, 'BodyStyle': 'Coupe', 'WofExpires': '/Date(0)/', 'NumberPlate': None, 'ImportHistory': None, 'Transmission': 'Manual', 'EngineSize': 0, 'ListingLength': None, 'StereoDescription': None, 'Category': '0001-0268-7081-', 'Title': 'Bentley Continental 1999', 'Owners': 0, 'IsDealer': False, 'Cylinders': 0, 'AsAt': '/Date(1457728757951)/', 'Odometer': 2000, 'Vin': None, 'Year': 1999, 'StartDate': '/Date(1457326119847)/', 'Region': 'Manawatu', 'Model': 'Continental', 'PriceDisplay': '$100.00', 'Suburb': 'Palmerston North', 'EndDate': '/Date(1457930919847)/', 'RegistrationExpires': '/Date(0)/', 'NoteDate': '/Date(0)/', 'ListingId': 4550689, 'Make': 'Bentley'}]
TotalCount1
How do i extract the say, odometer reading from the entry and add it to a csv file
struct = r3.json()
print(struct)
{'TotalCount': 1, 'PageSize': 1, 'FoundCategories': [], 'Page': 1, 'List': [{'AsAt': '/Date(1457733660023)/', 'Model': 'Continental', 'Suburb': 'Palmerston North', 'NoteDate': '/Date(0)/', 'PriceDisplay': '$100.00', 'EndDate': '/Date(1457930919847)/', 'RegistrationExpires': '/Date(0)/', 'StartPrice': 100.0, 'Owners': 0, 'ListingLength': None, 'CategoryPath': '/Trade-Me-Motors/Cars/Bentley', 'ListingId': 4550689, 'Subtitle': 'sdf', 'Category': '0001-0268-7081-', 'StartDate': '/Date(1457326119847)/', 'Year': 1999, 'WofExpires': '/Date(0)/', 'ExteriorColour': None, 'Vin': None, 'EngineSize': 0, 'Doors': 0, 'BodyStyle': 'Coupe', 'Title': 'Bentley Continental 1999', 'IsDealer': False, 'Make': 'Bentley', 'Transmission': 'Manual', 'Fuel': None, 'ImportHistory': None, 'Odometer': 2000, 'StereoDescription': None, 'Region': 'Manawatu', 'BestContactTime': None, 'Cylinders': 0, 'NumberPlate': None}]}