title: How to get the protocol (http or https) of the website using Python
body: <p>I'm just thinking about how we can imitate how browser, say Chrome, detects the protocol of the website with Python. For example we type "stackoverflow.com" on the address bar, then press Enter, browser can automatically detects and change the url to "<a href="https://stackoverflow.com">https://stackoverflow.com</a>" (add website's protocol), I wonder how we can do it in Python, exactly like:</p>
  
  <pre><code>url = "stackoverflow.com"
  browser = Browser (url) # Browser is a class that we can get website content from url, get its protocol,...
  print browser.protocol
  </code></pre>
  
  <blockquote>
    <p>https</p>
  </blockquote>
  
  <p>Is there any library or package that help do this? Thanks a lot.</p>
  
  <p>Edit: My question is unique since other question ask how to redirect to https if we enter http, as I mention, can we automatically detect at the first stage without dummy protocol?</p>