How to get multiple lines <li> below <ul> tag with regex in python
Question: I got this HTML tags that I've pulled from a website:

    
    
    <ul><li>Some Keys in the UL List</li>
    </ul>
    <li>HKEY_LOCAL_MACHINE\SOFTWARE\Description</li>
    <li>HKEY_LOCAL_MACHINE\SOFTWARE\Description\Microsoft</li>
    <li>HKEY_LOCAL_MACHINE\SOFTWARE\Description\Microsoft\Rpc</li>
    <li>HKEY_LOCAL_MACHINE\SOFTWARE\Description\Microsoft\Rpc\UuidTemporaryData</li>
    </ul></ul>
    
    <ul><li>Some objects in the UL LIST</li>
    </ul>
    <li>_SHuassist.mtx</li>
    <li>MuteX.mtx</li>
    <li>Something.mtx</li>
    <li>Default.mtx</li>
    <li>3$5.mtx</li>
    </ul></ul>
    

How can I get the lines(text beteween `<li>` tags) between the `<ul>` tags.
They don't have any class to diff then.

I don't know too much about BeautifulSoup and Regex.

I want this result as example:

    
    
    <li>_SHuassist.mtx</li>
    <li>MuteX.mtx</li>
    <li>Something.mtx</li>
    <li>Default.mtx</li>
    <li>3$5.mtx</li>
    


Answer: With `BeautifulSoup`:

    
    
    >>> html = textabove
    >>> from bs4 import BeautifulSoup as BS
    >>> soup = BS(html)
    >>> for ultag in soup.findAll('ul'):
    ...     for litag in ultag.findAll('li'):
    ...         print litag.text
    

Which prints:

    
    
    Some Keys in the UL List
    Some objects in the UL LIST
    

* * *

To get the latter `<li>` tags:

    
    
    >>> for litag in soup.findAll('li'):
    ...     if litag.text.endswith('.mtx'):
    ...         print litag
    ...         
    <li>_SHuassist.mtx</li>
    <li>MuteX.mtx</li>
    <li>Something.mtx</li>
    <li>Default.mtx</li>
    <li>3$5.mtx</li>
    

