擅长:python、mysql、java
<p>你可以用<a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>。你知道吗</p>
<pre><code>>>> from bs4 import BeautifulSoup
>>> s = '''Ecole Polytechnique, maar hij bleef daar slechts tot <TIMEX3 tid="t5" type="DATE" value="1888">1888</TIMEX3>.
Daarna had hij een korte carriere bij het leger als officier d'artillerie in <TIMEX3 tid="t6" type="DATE" value="1889">1889</TIMEX3>'''
>>> soup = BeautifulSoup(s)
>>> [i.text for i in soup.find_all('timex3')]
['1888', '1889']
>>> [i['value'] for i in soup.find_all('timex3')]
['1888', '1889']
>>> [i['value'] for i in soup.find_all('timex3') if i.has_attr("value")]
['1888', '1889']
</code></pre>