beautifulsoup: find the n-th element's sibling

Posted by deostroll on Stack Overflow See other posts from Stack Overflow or by deostroll
Published on 2010-04-10T13:25:29Z Indexed on 2010/04/10 13:53 UTC
Read the original article Hit count: 357

Filed under:
|
|
|

I have a complex html DOM tree of the following nature:

<table>
    ...
    <tr>
        <td>
            ...
        </td>
        <td>
            <table>
                <tr>
                    <td>
                        <!-- inner most table -->
                        <table>
                            ...
                        </table>

                        <h2>This is hell!</h2>
                    <td>
                </tr>
            </table>
        </td>
    </tr>
</table>

I have some logic to find out the inner most table. But after having found it, I need to get the next sibling element (h2). Is there anyway you can do this?

© Stack Overflow or respective owner

Related posts about python

Related posts about beautifulsoup