title: How do you read contents of adjacent html element using Python and BS4?
body: <p>Using Python and BeautifulSoup4, how can I read the next html element after finding a particular link in the page source. For example, in this snippet of page source:</p>
  
  <pre><code>&lt;a class="" onclick="" href="http://moodle.example.com/mod/resource/view.php?id=16952"&gt;&lt;img src="http://moodle.example.com/theme/image.php/afterburner/core/1410701261/f/document-24" class="iconlarge activityicon" alt=" " role="presentation" /&gt;&lt;span class="instancename"&gt;100 Days of English&lt;span class="accesshide " &gt; File&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  
  <p>I am able to extract the link to the resource, but need the file type, which can be identified from the 'img' tag that immediately follows from the end of the 'src' link 'document-24' in the example here. (pdf-24, powerpoint-24 are examples of other file type indicators)</p>
  
  <p>Current code:</p>
  
  <pre><code>for resource in soup.find_all('a'):
      if '/mod/resource/view.php?id=' in resource.get('href'):
          file_list.append(str(resource.get('href')))
  </code></pre>
  
  <p>Gets me all of the links to the resources (which I then download using Mechanize).</p>