title: Python - Split url into its components
body: <p>I have a huge list of urls that are all like this:</p>
  
  <pre><code>http://www.example.com/site/section1/VAR1/VAR2
  </code></pre>
  
  <p>Where VAR1 and VAR2 are the dynamic elements of the url. What I want to do is to extract from this url string only the VAR1. I've tried to use <a href="https://docs.python.org/2/library/urlparse.html" rel="noreferrer">urlparse</a> but the output look like this:</p>
  
  <pre><code>ParseResult(scheme='http', netloc='www.example.com', path='/site/section1/VAR1/VAR2', params='', query='', fragment='')
  </code></pre>