Email a notification when detecting changes on a website
You do not need to find the differences manually, you can use difflib.SequenceMatcher:

I think this is what you need:

&gt;&gt;&gt; a, b = "foobxr", "foobar"
&gt;&gt;&gt; diffs = difflib.SequenceMatcher(None, a, b).get_matching_blocks()
&gt;&gt;&gt; diffs
[Match(a=0, b=0, size=4), Match(a=5, b=5, size=1), Match(a=6, b=6, size=0)]
&gt;&gt;&gt; max((a, b), key=len)[diffs[0].size : diffs[1].a]
'x'


Specific except

Specify what you want to except exactly. Bare except catches even typos!

Use a logger

You print a lot of info, a logger is more flexible and can be very easily redirected to a file.

.format

You can make your messages more readable:

For example:

    print(date+": Start Monitoring... hash: "+self.urlhash)


Becomes:

print("{date}: Start Monitoring... Hash: {self.urlhash}".format(**locals()))


Or the more standard:

print("{}: Start Monitoring... Hash: {}".format(date, self.urlhash))




Thanks to @Jatimir for noticing that in python 3.6+ f-strings are a nice way to interpolate variables in strings with a clean sintax: for example:

print(f'{date}: Start Monitoring... Hash: {self.urlhash}')