title: Python: Retrieving information from nested divs of HTML code
body: <p>I'm trying to extract data from individual divs from HTML code using BeautifulSoup.</p>
  <p>Here's an example div that's a result of using <code>html.find_all('div')</code>:</p>
  <pre><code>&lt;div style=&quot;position: relative; background: background.png&quot;&gt;
      &lt;img class=&quot;onclick&quot; onclick=&quot;ajax_request()&quot; title=&quot;Text1&quot;/&gt;
      &lt;div style=&quot;position: absolute; bottom: 2px; right: 3px;&quot;&gt;
          Text2
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p><strong>How can I find <code>background.png</code>, <code>Text1</code> and <code>Text2</code> in the above code?</strong></p>
  <p>I've tried using <code>div.attrs</code>, but the only option is <code>style</code> that belongs to the first div (no information about the img tag or nested div).  Additionally, <code>div['style']</code>returns a string, so I'm not sure how to retrieve only the <code>background</code> value without using regexp.</p>