title: Getting a particular image from Wikipedia with BeautifulSoup
body: <p>I'm trying to get a particular image from some Wikipedia pages by using BeautifulSoup 4 with lxml as the parser. For example I'm trying to get the album cover on the right from this wikipedia page:
  <a href="http://en.wikipedia.org/wiki/Animal_House_(U.D.O._album)" rel="nofollow">http://en.wikipedia.org/wiki/Animal_House_(U.D.O._album)</a></p>
  
  <p>The function that does the scraping is this:</p>
  
  <pre><code>def get_cover_from_wikipedia(url):
      r = requests.get(url)
      if r.status_code == 200:
          soup = BeautifulSoup(r.content, 'lxml')
          elements = soup.find_all('a', class_='image')
          for element in elements:
              print '%s\n\n' % element.prettify()
  
      return False
  </code></pre>
  
  <p>the output of the print is as follows:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;a class="image" href="/wiki/File:Question_book-new.svg"&gt;
   &lt;img alt="" data-file-height="204" data-file-width="262" height="39" src="//upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/50px-Question_book-new.svg.png" srcset="//upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/75px-Question_book-new.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/9/99/Question_book-new.svg/100px-Question_book-new.svg.png 2x" width="50"/&gt;
  &lt;/a&gt;
  
  &lt;a class="image" href="/wiki/File:UDO_animal_house.jpg"&gt;
   &lt;img alt="" data-file-height="302" data-file-width="300" height="221" src="//upload.wikimedia.org/wikipedia/en/thumb/4/4e/UDO_animal_house.jpg/220px-UDO_animal_house.jpg" srcset="//upload.wikimedia.org/wikipedia/en/4/4e/UDO_animal_house.jpg 1.5x, //upload.wikimedia.org/wikipedia/en/4/4e/UDO_animal_house.jpg 2x" width="220"/&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>the image I want to pull out is the image in the second block that starts with <code>&lt;a class...</code>, not the book image which is the image in the first block</p>
  
  <p>what I want to accomplish here is:</p>
  
  <ol>
  <li><p>I only want to get the links specified with <code>src</code>, not everything that comes with the class.</p></li>
  <li><p>I want to be able to distinguish between the book image and image I want to pull out. The book image is there because if you check the Wikipedia page, it says the article need citations and there is a book image there. Apparently it matches my search for tag <code>a</code> and class <code>image</code> but it might or might not be there depending on the article in question. </p></li>
  </ol>
  
  <p>What's the best way to get only the image I'm interested in, which is the image in the right side of the article?</p>