(Aug-07-2021, 01:05 AM)knight2000 Wrote: So my question is, how would I go about only extracting the 12 Aug please?After using
text
the parser has done it's job and can not do anymore.Can try to exclude/remove then span(with 6 days left) tag first,
but can just use regex to get text wanted when parser has done it's job.
>>> import re >>> >>> tag = soup.find('span', class_="nodeexpiry") >>> tag <span class="nodeexpiry"><i class="fa fa-calendar"></i> 12 Aug <span class="marker">6 days left</span> </span> >>> tag.text.strip() '12 Aug 6 days left' >>> >>> r = re.search(r'(\d+\s\w+)', tag.text.strip()) >>> r.group(1) '12 Aug'