tupian.py

import FLAG1
from FLAG2 import request
# '''网址'''  图片_百度百科  获取整个网页的代码
FLAG3 = 'http://172.16.1.7:999'
page = request.urlopen(FLAG4)
code = page.read()
code=code.decode('FLAG5')
 
# 正则表达式  编译
FLAG6 = 'src="(.+\.bmp)"'
reg = re.compile(pattern)
 
# 找到图片资源并下载到指定目录
imgs = reg.findall(code)
i = 0
for img in imgs:
    i = i + 1
    print(str(i)+img)
    request.urlretrieve(img,r'C:\Users\mask\Desktop\aa\133232\%s.jpg' %i)

 

 


FLAG1:re
FLAG2:urllib
FLAG3:Url
FLAG4:request.Request(url)
FLAG5:utf-8
FLAG6:pattern

import re
from urllib import request
url = 'http://www.nipic.com/show/10247670.html'
page = request.urlopen(request.Request(url))
code = page.read()
code=code.decode('utf-8')
print('Start') 
pattern = 'src="(.+\.bmp)"'
reg = re.compile(pattern)
print('Start2') 
imgs = reg.findall(code)
print(imgs)
i = 0
for img in imgs:
    i = i + 1
    print(str(i)+img)
    request.urlretrieve(img,r'/root/py/%s.jpg' %i)

 

你可能感兴趣的:(tupian.py)