I want to extract the text contents of <div id="UserInputtedText">......</div>
note that < > & "
are their html equivalents :(
.
here is the code I made:
import re
response='[<td width="100%" class="wrapText device-width" valign="top" style="overflow: hidden; border-collapse: collapse !important; border-spacing: 0 !important; border: none; display: inline-block; max-width:600px;"><h3 style="font-family: Helvetica, Arial, sans-serif; font-weight: normal; line-height: 19px; color: #231f20; text-align: left; font-size: 14px; margin: 0 0 2px; font-weight:none;" align="left"><div id="UserInputtedText">Hi Dear ,<br /><br />we hope you enjoy your shopping with us !<br />please leave us a positive feedback on the feedback section on your purchase history<br />You can click the button next to the item and leave a feedback there we will REALLY appreciate that !<br />Have a Great Day &amp; STAY SAFE !</div></h3>]'
pattern 1= (\w+\s\w+[=][&]\w+[;]\w+[&]\w+[;][&]\w+[;])
# this is pattern 1 : div id="UserInputtedText">
pattern 2 =([&]\w+[;][/]\w+[&]\w+[;][&]\w+[;][/]\w+[&]\w+[;])
# this is pattern 2 : </div></h3>
pattern=re.search(r'(\w+\s\w+[=][&]\w+[;]\w+[&]\w+[;][&]\w+[;])(.*)([&]\w+[;][/]\w+[&]\w+[;][&]\w+[;][/]\w+[&]\w+[;])',response)
print(pattern.group(2))