-3
<div class="available-date-component">Available 4/1 at 9:00 AM</div>

I am trying to extract text from the html div above using the code below

date = page.find('div', {'class' : 'available-date-component'}) 
print(date.string) # this line needs to be fixed

Does anyone have any suggestsions on how I can only print 'Available 4/1 at 9:00 AM' isntead of the entire div?

  • What's the question? – BrokenBenchmark Mar 30 '22 at 01:16
  • `date.string`, `date.text`, as well as `date.get_text()` should work based on provided information. Would be great to improve your question with some more details, so that everybody could reproduce your issue, Thanks – HedgeHog Mar 30 '22 at 06:28

1 Answers1

0
def clean(raw_html):
    cleaner = re.compile('<.*?>')
    cleantext = re.sub(cleaner, '', raw_html)
    return cleantext

I ended up passing the html div through this function that removes all of the tags and leaves the text that I wanted.