Python: Parse web content for lines containing a specific character and store into a file
Question: I am new to python. I have this webpage containing the contents:

    
    
    <Response>
    <Value type="ABC">107544</Value>
    <Value type="EFG">10544</Value>
    <Value type="ABC">77544</Value>
    

I would like to parse lines containing ABC and store only the numbers within a
temporary text file. How can I do this?

Currently I have

    
    
    htmlpage = urllib2.urlopen(<URL>)
    result = htmlpage.read()
    


Answer: Put your result into `BeautifulSoup`, and you will be able to extract any data
very easily without regex

# UPDATED:

    
    
    from bs4 import BeautifulSoup
    
    result = '''<div class="test">
                 <a href="example">Result 1</a>
                </div>
    
                <div class="test">
                 <a href="example2">Result 2</a>
                </div>'''
    
    soup = BeautifulSoup(result)
    
    for div in soup.findAll('div', attrs={'class':'test'}):
        print div.find('a').text
    
    Result 1
    Result 2
    

