title: regex pattern in python for parsing HTML title tags
body: <p>I am learning to use both the <code>re</code> module and the <code>urllib</code> module in python and attempting to write a simple web scraper. Here's the code I've written to scrape just the title of websites:</p>
  
  <pre><code>#!/usr/bin/python
  
  import urllib
  import re
  
  urls=["http://google.com","https://facebook.com","http://reddit.com"]
  
  i=0
  
  these_regex="&lt;title&gt;(.+?)&lt;/title&gt;"
  pattern=re.compile(these_regex)
  
  while(i&lt;len(urls)):
          htmlfile=urllib.urlopen(urls[i])
          htmltext=htmlfile.read()
          titles=re.findall(pattern,htmltext)
          print titles
          i+=1
  </code></pre>
  
  <p>This gives the correct output for Google and Reddit but not for Facebook - like so:</p>
  
  <pre><code>['Google']
  []
  ['reddit: the front page of the internet']
  </code></pre>
  
  <p>This is because, I found that on Facebook's page the <code>title</code> tag is as follows: <code>&lt;title id="pageTitle"&gt;</code>. To accomodate for the additional <code>id=</code>, I modified the <code>these_regex</code> variable as follows: <code>these_regex="&lt;title.+?&gt;(.+?)&lt;/title&gt;"</code>. But this gives the following output:</p>
  
  <pre><code>[]
  ['Welcome to Facebook \xe2\x80\x94 Log in, sign up or learn more']
  []
  </code></pre>
  
  <p>How would I combine both so that I can take into account any additional parameters passed within the <code>title</code> tag?</p>