Answers for "python regex in html"

0

python regex in html

>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup("<p>Some<b>bad<i>HTML")
>>> print soup.prettify()
<html>
<body>
<p>
Some
<b>
bad
<i>
HTML
import re
print(soup.find_all(re.compile("(p|div)")))
Posted by: Guest on May-11-2021

Browse Popular Code Answers by Language