I have a html document with many lines like:
<option value="29">Soil Temperature (<i>2002-10-17</i>)</option>
or like:
<option value="STO">Soil & Air Temperature (2002-10-17)</option>
For each line, I want to check if the line contains the date in the YYYY-mm-dd format and if it does, I want to extract the date.
The following code does not work:
line = '<option value="29">Soil Temperature (<i>2002-10-17</i>)</option>'
date = datetime.datetime.strptime(line, '%Y-%m-%d')
It gives me the error:
ValueError: time data '<option value="29">Soil Temperature (<i>2002-10-17</i>)</option>' does not match format '%Y-%m-%d'
Any way how to easily extract the date?