Use urlparse.urljoin to create the links from relative links. Refactoring