Advertisement
Guest User

Untitled

a guest
Nov 21st, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import requests
  2. import urllib.request
  3. import re
  4. from pathlib import Path
  5.  
  6.  
  7. START_FOLDER = 26
  8.  
  9. num = 0
  10. loss = 0
  11. for num1 in range(START_FOLDER, 16*16):
  12.     for num in range(16,16*16):
  13.         try:
  14.             num_hex = hex(num).split('x')[-1].upper()
  15.             num1_hex = hex(num1).split('x')[-1]
  16.             folder = f'ad{num1_hex}'
  17.             path = folder + str(num_hex)
  18.             result = requests.get(url=f'http://gs.3g.cn/D/{path}/w')
  19.             pic_url = result.url
  20.             pic_url = re.sub('&t=image/jpeg&w=100&h=200', "", pic_url)
  21.             pic_url = re.sub("/mms/v14/index.html\?u=http%3A%2F%2Fgosms.gomocdn.com%2F", "/", pic_url)
  22.             num += 1
  23.             Path(folder).mkdir(parents=True, exist_ok=True)
  24.             if 'jpg' in pic_url:
  25.                 urllib.request.urlretrieve(pic_url, f'{folder}\\photo_{path}.jpg')
  26.                 print(pic_url)
  27.                 loss = 0
  28.         except Exception:
  29.             loss+=1
  30.             if loss == 100:
  31.                 loss = 0
  32.                 break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement