anilchahal7

Image Download From After Reading URL From File

Jun 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import urllib
  2. import urllib2
  3. import re
  4. file = open(‘abc.txt, ‘r’)
  5. x = file.readlines()
  6. for index in range(len(x)):
  7.     if index == 0:
  8.         continue
  9.     else:
  10.         url = x[index]
  11.         Resp = urllib2.urlopen(url)
  12.         request = urllib2.Request(url)
  13.         img = urllib2.urlopen(request).read()
  14.         with open (‘image’ + str(index) + ‘.jpg, ‘w’) as f: f.write(img)
Add Comment
Please, Sign In to add comment