BeautifulSoup/Python/HTML - Return the div class right after a specific div class
Question: Example:

    
    
    <div class="label">Employee Count</div>
    <div class="field">331,000</div>
    

How can I use beautiful soup (or a different python lib) to search an HTML
file for "Employee Count" then return the value (331,000) that comes right
after it?

Using

    
    
    result = soup.body.find(text='Employee Count')
    

I can find Employee Count, but how can I return the field right after it?


Answer: Find the `div` element with `Employee Count` text and get the [next
sibling](http://www.crummy.com/software/BeautifulSoup/bs4/doc/#find-next-
siblings-and-find-next-sibling):

    
    
    soup.find('div', text='Employee Count').find_next_sibling().text
    

Demo:

    
    
    >>> from bs4 import BeautifulSoup
    >>> data = """
    ... <body>
    ... <div class="label">Employee Count</div>
    ... <div class="field">331,000</div>
    ... </body>
    ... """
    >>> 
    >>> soup = BeautifulSoup(data)
    >>> soup.find('div', text='Employee Count').find_next_sibling().text
    331,000
    

