title: Handling relative URLs in a locally-saved HTML file
body: <p>When <code>urllib2</code> is used to store to disk the contents of a page like <a href="https://huddlebuy.workable.com/jobs/194756" rel="nofollow noreferrer">this</a> thus:</p>
  
  <pre><code>url = 'https://huddlebuy.workable.com/jobs/194756'
  response = urllib2.urlopen(url)
  content = response.read()
  with open('spec.html', 'w') as spec:
      print &gt;&gt;spec, content
  </code></pre>
  
  <p>When spec.thml is opened in a browser, we can see that the URLs behind links such as:</p>
  
  <p><a href="https://i.stack.imgur.com/1BNX3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1BNX3.png" alt="enter image description here"></a></p>
  
  <p>.. go correctly to their underling links (<a href="http://www.perkbox.co.uk/" rel="nofollow noreferrer">http://www.perkbox.co.uk/</a>, in this case). Relative URLs though, such as <code>/jobs/194756/candidates/new</code>, that of the Apply button:</p>
  
  <p><a href="https://i.stack.imgur.com/onSAi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/onSAi.png" alt="enter image description here"></a></p>
  
  <p>... point to a location on disk, which obviously won't exist:</p>
  
  <pre><code>file:///jobs/194756/candidates/new
  </code></pre>
  
  <p>Is there a known way of avoiding this, without manually reconstructing the full URL (base URL + relative URL) and then doing a find/replace in the source before saving? </p>