def dns_lookup(address):
    subprocess.call("ipconfig /flushdns", stdout=False, stderr=False)
    query = socket.getaddrinfo(address, 80)
    query = ".".join([str(x) for x in query])
    query = query.split("'")[3]
    print address, "-", query
    date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")
    
    if os.path.isfile("history.txt"):
        FILE  = open ("history.txt","r" )   
        entries = FILE.readlines()
        FILE.close()
        lastentry = entries[-1].split("|")[1]

        if debug:
            print query.strip, lastentry
            print address.strip().lower(), entries[-1].split("|")[0].strip().lower()

        if (address.strip().lower() == entries[-1].split("|")[0].strip().lower()):
            if query.strip() != lastentry.strip():
                print (lastentry.strip(), query) %"DNS Change Detected! (Old: %s - New: %s)\n"
                winsound.PlaySound("SystemAsterisk", winsound.SND_ALIAS)
                    
        line = address + "|" + query + "|" + date + "\n"
        FILE = open("history.txt", "a")
        FILE.writelines(line)
        FILE.close()
    else:
        line = address + "|" + query + "|" + date + "\n"
        FILE = open("history.txt", "w")
        FILE.writelines(line)
        FILE.close()
dataset/ETHPy150Open mertsarica/hack4career/codes/dns_checker.py/dns_lookup/swapped operands of `%`