Skip to content
Advertisement

Python regex to extract html paragraph

I’m trying to extract parapgraphs from HTML by using the following line of code:

JavaScript

but it returns none even though I know there is. Why?

Advertisement

Answer

Why don’t use an HTML parser to, well, parse HTML. Example using BeautifulSoup:

JavaScript

Note that text=True helps to filter out empty paragraphs.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement