title: Opening Multiple Pages with Mechanize in Python
body: <p>I'm trying to open multiple pages following a certain format using mechanize. I want to start with a certain page, and have mechanize follow all the links that have a certain class or piece of text in a link. For example, the root url would be something like</p>
  
  <p><code>http://hansard.millbanksystems.com/offices/prime-minister</code></p>
  
  <p>and I want to follow every link on the page that has a format such as </p>
  
  <pre><code>&lt;li class='office-holder'&gt;&lt;a href="http://hansard.millbanksystems.com/people/mr-tony-blair"&gt;Mr Tony Blair&lt;/a&gt; May  2, 1997 - June 27, 2007&lt;/li&gt;
  </code></pre>
  
  <p>In other words, I want to follow every link that has the class 'office-holder' or that has /people/ in the URL. I've tried the following code, but it hasn't worked.</p>
  
  <pre><code>import mechanize
  
  br = mechanize.Browser()
  response = br.open("http://hansard.millbanksystems.com/offices/prime-minister")
  links = br.links(url_regex="/people/")
  
  print links
  </code></pre>
  
  <p>I'm trying to print the links so I can make sure that I'm getting the right links/information before writing any more code. The error(?) I get from this is:</p>
  
  <pre><code>&lt;generator object _filter_links at 0x10121e6e0&gt;
  </code></pre>
  
  <p>Any pointers or tips are appreciated. </p>