emmmmm
怎么说呢,7年的老河粉了,闲来无事就....
1 import os 2 import time 3 import requests 4 5 url = 'https://h5.48.cn/resource/jsonp/allmembers.php?gid=00' 6 headers = { 7 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' 8 '(KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36' 9 } 10 r = requests.get(url, headers=headers) 11 r = r.json() 12 13 member_name = list(map(lambda x:x['sname'], r['rows'])) 14 member_id = list(map(lambda x:x['sid'], r['rows'])) 15 team_id = list(map(lambda x:x['tname'], r['rows'])) 16 path = "C:\\Users\\16671\\Desktop\\SNH48\\" 17 18 def main(): 19 id = 0 20 time.sleep(0.5) 21 for v in member_id: 22 os.mkdir(path + team_id[id] + " " +member_name[id]) 23 os.chdir(path + team_id[id] + " " + member_name[id]) 24 id += 1 25 for u in range(5): 26 time.sleep(0.5) 27 member_links = 'https://www.snh48.com/images/member/gs4_' + str(v) + '_' + str(u) + '.jpg' 28 im = requests.get(member_links) 29 if im.status_code == 200: 30 print("正在下载:%s" % member_links) 31 with open(str(u) + '.jpg', 'wb') as f: 32 f.write(im.content) 33 34 if __name__ == '__main__': 35 main()
ps: 参考大佬的代码写的,毕竟刚写这个的时候,前端可是一点都不懂