Use urlparse() host and port parsing if possible

* urlparse() result attributes added in Python 2.5
* Scheme and host are automatically lowercased
Replace deprecated “string” module function calls

* Methods on string objects introduced in Python 2.0
* strip() before int() etc is redundant
* Use isalpha() etc instead of string.letters etc in many cases
* Use partition() or split() where appropriate instead of slicing via find()
  and index()
* Avoid map() by translating strings before splitting