#encoding:utf8import requestsimport jsonimport redemo = requests.get(‘http://www.toutiao.com/api/pc/feed/?category=gallery_detail&utm_source=toutiao&max_behot_time=0&as=A1E5F9D180C2473&cp=5910C214D7E3BE1‘).textdemo1 = json.loads(demo)n = 0for i in demo1[‘data‘]: the_url = ‘http://www.toutiao.com/‘+ i[‘source_url‘] contents = requests.get(the_url).text demo = re.compile(‘gallery = {(.*?)}‘,re.S) list = demo.findall(contents) for i in list: n=n+1 print(i) t = requests.get(i[33:85].replace(‘\/‘,‘/‘)).content op = open(str(n)+‘.jpg‘,‘wb+‘) op.write(t) op.close()
时间: 2024-12-22 17:53:01