How to get the div class which contains another specific div class in Python with Beautifulsoup?
<p>I have this kind of code:</p>

<pre><code>&lt;div class = first&gt;
   &lt;div class = second&gt;
   &lt;div class = fourth&gt;
&lt;div class = first&gt;
   &lt;div class = second&gt;
   &lt;div class = third&gt; 
&lt;div class = first&gt;
   &lt;div class = second&gt;
   &lt;div class = fourth&gt;
</code></pre>

<p>The information in div third is different from div fourth, but I need the information in the div second which is in the same div first situated as div third is. So the div third I need just to identify the correct div second. </p>

<p>To be more precise: 
I need something that will do the following: If div.first contains div.third, then store the specific div.second (or the specific div first) of this element in a variable (to catch some text out of it).</p>

<p>I've tried it with find_all and parent or child operations, but I wasn't able to solve this.
Any help would be really appreciated.</p>

<p><strong>Update (example):</strong>
An example with a flight search site:</p>

<pre><code>&lt;div class = booking class&gt;
   &lt;div class = price&gt;
   &lt;div class = non refundable&gt;

&lt;div class = booking class&gt;
   &lt;div class = price&gt;
   &lt;div class = refundable&gt;

&lt;div class = booking class&gt;
   &lt;div class = price&gt;
   &lt;div class = non refundable&gt;
</code></pre>

<p>I need the content of the div class = price when div class = refundable.
Hope this makes it more clearly.</p>