I'm trying to pull the date time out from:
<time datetime="2015-07-25T10:06:46-0700">2015-07-25 10:06am</time>
Any help would be appreciated, thanks!
I'm trying to pull the date time out from:
<time datetime="2015-07-25T10:06:46-0700">2015-07-25 10:06am</time>
Any help would be appreciated, thanks!
Use BeautifulSoup
parser.
>>> html = '''<time datetime="2015-07-25T10:06:46-0700">2015-07-25 10:06am</time>'''
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup(html)
>>> soup.findAll('time')[0].text
'2015-07-25 10:06am'
With re
,
re.search(r'<time\b[^>]*>([^<>]*)</time>', s).group(1)