python re正则表达式抓取图片并下载

python re正则表达式抓取图片并下载


import requests
import re


url="http://www.x14hack.com/?id=388"

response=requests.get(url)
html=response.content.decode('utf-8')

reSimg= '<img class="ue-image" src="(.*?)"'

data=re.findall(reSimg,html)
for item in data:
    if not item.startswith("http"):
        item="http:"+item

    print("Python program download pictures...")

    response =requests.get(item)
    data=response.content
    with open("d:\image.jpg","wb")as f:
     f.write(data)


捕获880.PNG