Hoping someone can help me out because for the life of me I cannot figure out why I'm getting different results.
I want to compare two files that should be exactly the same. In linux I run the following command:
diff file1 file2
It turns me to the command line as there is no difference.
Now when I run the same command from Python:
results = os.system("diff caesars_terms.txt caesars_termsa.txt")
It says there is a difference. To really screw things up, if I break that command out from the entire script it works fine.
Script below:
#!/usr/bin/python
from urllib import urlopen
import nltk
import difflib
import os
#Caesar's URL for Terms and Conditions
url = "
https://www.caesarscasino.com/en/policies/terms-conditions"
#Opens the URL and reads the HTML
html = urlopen(url).read()
#Cleans the HTML from the file providing only text
raw = nltk.clean_html(html)
#Creates a file and stores the value in said file
f = open("caesars_termsa.txt","w")
f.write(raw)
#Compares the two different files
results = os.system("diff caesars_terms.txt caesars_termsa.txt")
#Displays a passed or failed message as a result of the comparisons of the files
if not int(results):
print "PASSED"
else:
print "FAILED"