How can I get/ print only the lines of a big multiline text within one <p>
tag containing a certain string? On the website the lines are realized with <br>
tags. There is no closing </p>
tag.
Basic structure of the website:
<p style="line-height: 150%">
I need a big cup of coffee and cookies.
<br>
I do not like tea with milk.
<br>
I can't live without coffee and cookies.
<br>
...
Let's assume I want to get/ print only the lines containing the words "coffee and cookies". So, in this case only the first and third "line"/ sentence of this <p>
should be printed.
I have Beautiful Soup 4.6.3 installed under Python 3.7.1.
findAll seems to be tag-orientated and return the whole <p>
, right? So how can I realize it? Maybe with regex or other pattern?