title: How to Handle Relative/Full URLs in Pytohn?
body: <p>As we know and html page may include link in different ways, for example we can include an image like this:</p>
  <p>Suppose we are currently at: <a href="https://example.com/folder" rel="nofollow noreferrer">https://example.com/folder</a></p>
  <p><code>https://example.com/images/picture.jpg</code> which resolves to the same.</p>
  <p><code>/images/picture.jpg</code> which resolves to: <code>https://example.com/images/picture.jpg</code>.</p>
  <p><code>images/picture.jpg</code> which resolves to: <code>https://example.com/folder/images/picture.jpg</code>.</p>
  <p>How can python Handle all those cases for me?</p>
  <hr />
  <p><strong>My previous approach (which is wrong):</strong></p>
  <pre><code>response = requests.get(url)
  ...
  for link in links:
      if link.startswith('/'):
          print(url+link)
      else:
          print(url)
  </code></pre>
  <p>Another reason for why it's wrong is because when visiting <code>https://example.com</code> we might get redirected to: <code>https://example.com/homepage?ignore=yes</code> so the base url isn't any longer the visited one but <code>https://example.com/homepage/</code></p>