Picture Downloader

Import Re 
Import urllib.request


: class Picture (Object)

DEF RUN (Self):
# define variables get url address to download the picture
url = "http://www.txt100.com/bbrvtwyhknv/85774146.html"

the Response = urllib .request.urlopen (url) .read (). decode ( 'UTF-8')
imglist = re.findall ( 'src = "(. +? \. JPG)"', the Response)
the X-= 0
for imgUrl in imglist :
imgUrl = 'http://www.txt100.com' + imgUrl
urllib.request.urlretrieve (imgUrl, "./{}.jpg".format(x))
X = X +. 1
Print (" first ", x "Zhang finished downloading")


IF __name__ == '__main__':
the p-Picture = ()
p.run ()

Guess you like

Origin www.cnblogs.com/victorstudy/p/11237287.html