I want to compare 2 Python response strings and print out the differences, here is my code right now:
import requests import json import time
getFirst = requests.get("https://api-mainnet.magiceden.dev/v2/collections?offset=0&limit=1") liveRN = json.dumps(getFirst.json(), indent=4)
while True: get = requests.get("https://api-mainnet.magiceden.dev/v2/collections?offset=0&limit=1") dataPretty = json.dumps(get.json(), indent=4) data = get.json()
if get.status_code == 200:
print("ok")
if dataPretty != data:
for item in data:
if str(item) not in liveRN:
send = 1
print(f"Found difference: {item}")
symbol = item['symbol']
img = item['image']
name = item['name']
description = item['description']
print(symbol)
print(img)
print(name)
else:
print("Didnt find")
else:
print("No change")
time.sleep(15)
I only want to print the items when the two repsonses dont match but right now its printing the items I want even when the strings do match.
I tried to see add another if condition where if the 2 request response match it wont do anything and just pass but that didnt work