title: Extract link and text if certain strings are found - BeautifulSoup
body: <p>I'm trying to run beautifulSoup to extract links and text from a website (I have permission)</p>
  
  <p>I run the following code to get the links and the text: </p>
  
  <pre><code>import requests
  from bs4 import BeautifulSoup 
  
  url = "http://implementconsultinggroup.com/career/#/6257"
  r = requests.get(url)
  
  soup = BeautifulSoup(r.content)
  
  links = soup.find_all("a")
  
  for link in links:
       if "career" in link.get("href"):
               print "&lt;a href='%s'&gt;%s&lt;/a&gt;" %(link.get("href"), link.text)
  </code></pre>
  
  <p>Which give me the following output:</p>
  
  <pre><code>View Position
  
  &lt;/a&gt;
  &lt;a href='/career/business-analyst-within-human-capital-management/'&gt;
  Business analyst within human capital management
  COPENHAGEN • We are looking for an ambitious student with an interest in HR 
  who is passionate about working in the cross-field of people management, 
  business and technology
  
  
  
  
  View Position
  
  &lt;/a&gt;
  &lt;a href='/career/management-consultants-within-strategic-workforce-planning/'&gt;
  Management consultants within strategic workforce planning
  COPENHAGEN • We are looking for consultants with profound experience from 
  other consultancies
  
  
  
  
  View Position
  
  &lt;/a&gt;
  &lt;a href='/career/management-consultants-within-supply-chain-strategy-
  production-and-process-management/'&gt;
  Management consultants within supply chain strategy, production and process 
  management
  MALMÖ • We are looking for talented graduates who want a career in management 
  consulting
  </code></pre>
  
  <p>Which is almost correct, however I ONLY want the positions to be returned if they have the name COPENHAGEN in the text (ie above the MALMO position should not have been returned).</p>
  
  <p>The HTML Code for the site looks like this:</p>
  
  <pre><code>&lt;div class="small-12 medium-9 columns top-lined"&gt;
                                      &lt;a href="/career/management-consultants-within-supply-chain-management/" class="box-link"&gt;
                                      &lt;h2 class="article__title--tiny" data-searchable-text=""&gt;Management consultants within supply chain management&lt;/h2&gt;
                                      &lt;p class="article__longDescription" data-searchable-text=""&gt;COPENHAGEN • We are looking for bright graduates with a passion for supply chain management and supply chain planning for our planning and execution excellence team.&lt;/p&gt;
                                      &lt;div class="styled-link styled-icon"&gt;
                                          &lt;span class="icon icon-icon"&gt;
                                              &lt;i class="fa fa-chevron-right"&gt;&lt;/i&gt;
                                          &lt;/span&gt;
                                          &lt;span class="icon-text"&gt;View Position&lt;/span&gt;
                                      &lt;/div&gt;
                                  &lt;/a&gt;
                              &lt;/div&gt;
  </code></pre>