networked programs enter regular expressions work very nicely when your html is well formatted and predictable but since there are lot of "brokenhtml pages out therea solution only using regular expressions might either miss some valid links or end up with bad data this can be solved by using robust html parsing library parsing html using beautifulsoup even though html looks like xml and some pages are carefully constructed to be xmlmost html is generally broken in ways that cause an xml parser to reject the entire page of html as improperly formed there are number of python libraries which can help you parse html and extract data from the pages each of the libraries has its strengths and weaknesses and you can pick one based on your needs as an examplewe will simply parse some html input and extract links using the beautifulsoup library beautifulsoup tolerates highly flawed html and still lets you easily extract the data you need you can download and install the beautifulsoup code frominformation on installing beautifulsoup with the python package index tool pip is available atwe will use urllib to read the page and then use beautifulsoup to extract the href attributes from the anchor (atags to run thisdownload the beautifulsoup zip file and unzip it in the same directory as this file the xml format is described in the next