I have the following code and in the last if statement I just want to compare the two strings.
import dns.resolver
domain = "google.co.uk"
spf_wrong ='"v=spf1 -all"'
test_spf = dns.resolver.resolve(domain , 'TXT')
try:
for dns_data in test_spf:
if 'spf1' in str(dns_data):
dns_correct = dns_data
except:
print("SPF record not found")
pass
if dns_data == spf_wrong:
print("same")
else:
print("not same")
print(dns_correct)
print(spf_wrong)
To me, the output shows the exact same text. There is nothing different about it but I get the output:
not same
"v=spf1 -all"
"v=spf1 -all"
Finding another thread I then modified the if statement to the following:
if dns_data == spf_wrong:
print("same")
else:
print("not same")
print(repr(dns_correct))
print(repr(spf_wrong))
And now I get the following output:
not same
<DNS IN TXT rdata: "v=spf1 -all">
'"v=spf1 -all"'
So my question is, how do I act on this? Python thinks these strings are different and I think using the repr() function shows they are different, but I am not sure how to fix this.