1 import urllib.request 2 cnt=0 3 def instr(keystr): 4 st=keystr.find('(')+1 5 strhtml=keystr[st:len(keystr)-1] 6 return strhtml 7 8 def picsave(strJson,number): 9 global cnt 10 strdic=strJson['data']['archives'] 11 num=len(strdic) 12 for i in range(0,num,1): 13 cnt=cnt+1 14 strdic=strJson['data']['archives'][i] 15 print(strdic['pic']) 16 urllib.request.urlretrieve(strdic['pic'],'E:图片dnf\%s.jpg'%(cnt)) 17 18 def urlget(num): 19 for i in range(1,num,1): 20 url='https://api.bilibili.com/x/tag/ranking/archives?callback=jQuery172014070206081723846_1514982701564&tag_id=5033&rid=65&type=0&pn='+str(i)+'&ps=20&jsonp=jsonp&_=1514982702144' 21 response=urllib.request.urlopen(url) 22 html=response.read().decode('utf-8') 23 html=instr(html) 24 strJson=eval(html) 25 picsave(strJson,i) 26 27 urlget(6) 28 print("ok")