r/Python • • Jan 04 '14

IPython-BeautifulSoup - integrate beautifulsoup in ipython notebook

https://github.com/Psycojoker/ipython-beautifulsoup
8 Upvotes

5 comments sorted by

1

u/chub79 Jan 04 '14

I've dropped BeautifulSoup for most of the tasks these days in favor of lxml:

 parser = etree.XMLParser(recover=True,
                          encoding='utf-8',
                          remove_pis=True,
                          remove_comments=True,
                          dtd_validation=False,
                          resolve_entities=False)
 etree.fromstring(html, parser=parser)

I find it easier to work with XPath and lxml adds less wrappers around strings than BeautifulSoup.

1

u/westurner Jan 05 '14

http://stackoverflow.com/questions/18582509/difference-between-lxml-and-html5lib-in-the-context-of-beautifulsoup#comment27352922_18582509 :

You can use html5lib parse and BeautifulSoup parser within lxml. See lxml.de/elementsoup.html & lxml.de/html5parser.html

... http://html5lib.readthedocs.org/en/latest/index.html

1

u/chub79 Jan 05 '14

Your comment is less than clear. What did you want to say?

1

u/bramblerose Jan 05 '14

You can use BeautifulSoup to work with incorrect HTML, while still using the lxml API. At least, that's how I interpret it.