How to extract URLs matching a pattern
<p>I'm trying to extract URLs from a webpage with the following pattern :</p>

<blockquote>
  <p>'<a href="http://www.realclearpolitics.com/epolls/????/governor/??/" rel="nofollow">http://www.realclearpolitics.com/epolls/????/governor/??/</a><em>-</em>.html'</p>
</blockquote>

<p>My current code extracts all the links. How could I change my code to only extract URLs that match the pattern? Thank you!</p>

<pre><code>import requests
from bs4 import BeautifulSoup

def find_governor_races(html):
    url = html
    base_url = 'http://www.realclearpolitics.com/'
    page = requests.get(html).text
    soup = BeautifulSoup(page,'html.parser')  
    links = []
    for a in soup.findAll('a', href=True):
            links.append(a['href'])
find_governor_races('http://www.realclearpolitics.com/epolls/2010/governor/2010_elections_governor_map.html')
</code></pre>