"""
  @author: LinTao
  @time: 2022/10/24 22:58
  @desc:
"""

import re
import requests

source = '''
<p>
    啊飒飒
</p>
<p>
    <img src="/upload/90b36e4a563bad8ba1cf55a21a456886.jpeg" title="90b36e4a563bad8ba1cf55a21a456886.jpeg" alt="90b36e4a563bad8ba1cf55a21a456886.jpeg"/>
</p>
<p>
    asas
</p>
<p>
    <img src="/upload/mmexport1561284889076.jpg" title="mmexport1561284889076.jpg" alt="mmexport1561284889076.jpg"/>
</p>
<p>
    打发打发
</p>
<p>
    <img src="https://woniufile.oss-cn-hangzhou.aliyuncs.com/banner/banner.com.pc%20(1).jpg"/>
</p>
'''

# .*  贪婪模式（当前行查询最长匹配项）
# .+?  非贪婪模式，匹配最短字符串
list = re.findall('<img src="(.+?)"', source)
print(list)

for item in list:
    if item.startswith('http://') or item.startswith('https://'):
        resp = requests.get(item)
        with open('E:/PyCharm/project/woniuNote/resource/img/download.jpg', 'wb') as file:
            file.write(resp.content)
