import re


def _get_port(location):
   """ Extract port number from url.

   location -- string like http://anyurl:port/whatever/path
   return -- port number
   """
   port = re.findall('http://.*?:(\d+).*', location)
   return int(port[0]) if port else 80