我将如何使用 Python 正则表达式提取它?
How would I extract this with Python regular expressions?
我正在尝试从中提取日期时间:
<time datetime="2015-07-25T10:06:46-0700">2015-07-25 10:06am</time>
任何帮助将不胜感激,谢谢!
使用 BeautifulSoup
解析器。
>>> 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'
和re
,
re.search(r'<time\b[^>]*>([^<>]*)</time>', s).group(1)
我正在尝试从中提取日期时间:
<time datetime="2015-07-25T10:06:46-0700">2015-07-25 10:06am</time>
任何帮助将不胜感激,谢谢!
使用 BeautifulSoup
解析器。
>>> 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'
和re
,
re.search(r'<time\b[^>]*>([^<>]*)</time>', s).group(1)