Should line 147 read:
except HTTPException as e: print(str(e))
instead of
except HTTPException, e: print(str(e))
which gives me an error for python3.5.2
--edit--
I also needed to make the import explicit with python3.5.2 for line 5
from http:client import HTTPConnection, HTTPSConnection, HTTPException