#encoding:utf8
import requests
import json
import re
demo = requests.get('http://www.toutiao.com/api/pc/feed/?category=gallery_detail&utm_source=toutiao&max_behot_time=0&as=A1E5F9D180C2473&cp=5910C214D7E3BE1').text
demo1 = json.loads(demo)
n = 0
for 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()