if shopfloor get server url is a  real url that is  contains scheme and net location you may use urlparse urlparse to get port u urlparse urlparse shopfloor get server url self url u scheme s  d u hostname  self args port self args webservice 