python的正则表达式,需要引用内置库re,语法与javascript的类似,案例如下:

import re

import requests

r = requests.get("https://www.cnpack.org/showmaster.php?id=7&lang=zh-cn")

matches = re.findall('\\[(\\d{4}\\-\\d{2}\\-\\d{2})\\]</td>.*?width=\\*>(.*?)\n', r.text, flags=re.DOTALL)

for match in matches:

   print({"time":match[0],"content":match[1].replace('<img border="0" src="images/new.gif">','')})