Created
August 19, 2013 05:13
-
-
Save staticor/6265917 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> import re | |
| >>> s = '''<table> | |
| <tr> | |
| <td>序列号</td><td>DEIN3-39CD3-2093J3</td> | |
| <td>日期</td><td>2013年1月22日</td> | |
| <td>售价</td><td>392.70 元</td> | |
| <td>说明</td><td>仅限5用户使用</td> | |
| </tr> | |
| </table>''' | |
| >>> res = r'<td>(.*?)</td><td>(.*?)</td>' | |
| >>> m = re.findall(res,s,re.S|re.M) | |
| >>> m | |
| [('\xd0\xf2\xc1\xd0\xba\xc5', 'DEIN3-39CD3-2093J3'), ('\xc8\xd5\xc6\xda', '2013\xc4\xea1\xd4\xc222\xc8\xd5'), ('\xca\xdb\xbc\xdb', '392.70 \xd4\xaa'), ('\xcb\xb5\xc3\xf7', '\xbd\xf6\xcf\xde5\xd3\xc3\xbb\xa7\xca\xb9\xd3\xc3')] | |
| >>> for line in m: | |
| print line[0],line[1] | |
| 序列号 DEIN3-39CD3-2093J3 | |
| 日期 2013年1月22日 | |
| 售价 392.70 元 | |
| 说明 仅限5用户使用 | |
| >>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment