title: Extracting the correct link in multiple DIVs using beautiful soup. It is not a duplicate question
body: <p>The code below extracts links from multiple DIVs with identical class and prints them correctly. However in each DIV there are several links. I want to extract and print only the first link in each DIV. What Syntax should I use to accomplish this.     </p>
  
  <pre><code>This is the structure of the DIVs:
  
  &lt;div class="details"&gt;
      &lt;h1 class="detail_summary"&gt;&lt;a href="/detailed description/"&gt;cars&lt;/a&gt;&lt;/h1&gt;
      &lt;h1 class="detail_1"&gt;&lt;a href="/detailed description/"&gt;planes&lt;/a&gt;&lt;/h1&gt;
      &lt;h1 class="detail_2"&gt;&lt;a href="/detailed description/"&gt;bikes&lt;/a&gt;&lt;/h1&gt;
  &lt;/div&gt;   
  
  This is the code:     
  
  from urllib.request import urlopen
  from bs4 import BeautifulSoup
  html = urlopen('https://www.placeholder.com/')
  bs = BeautifulSoup(html.read(), 'html.parser')
  data = bs.findAll('div',attrs={'class':'details'})
  for div in data:
      links = div.findAll('a')
      for a in links:
          print (a['href'])
  </code></pre>