Crawler = Method for downloading images; Method for downloading images
Method 1:
Import urllib. requestfor x in range (1, 21): urllib. request. urlretrieve ("http: // url/" + str (x) + ". jpg ", 'audio s.jpg '% x)
Method 2:
Recommendation
Import requestsfor I, j in enumerate (range (1, 21): with open('{0}.jpg '. format (I), 'wb ') as file: file. write (requests. get ('https: // meiriyiwen.com/images/new_feed/bg_'{str (j?#'.jpg '). content)
Import requestsfor I, j in enumerate (imgUrlList): with open ('e:/12702.16.jpg '. format (I), 'wb ') as file: file. write (requests. get (j ). content)
The functions of the enumerate function are described as follows:
List _ = ['A', 'B', 'C'] for I, j in enumerate (list _): print ([I, j])
Output result:
[0, 'a'] [1, 'B'] [2, 'C']
Here I iterate over the index value of list _, while j iterates over the element value!