庭审公开网 刷刷刷
如需使用只需编辑range()范围
1 # -*- coding: UTF-8 -*- 2 ''' 3 Created on 2017年9月6日 4 @author: leilei 5 ''' 6 import urllib2 7 videoids=[] 8 print "获取视频个数..." 9 for i in range(1,50):#需要修改 10 pageurl = 'http://tingshen.court.gov.cn/court/cases?courtCode=1384&page=%d' % i 11 o = urllib2.urlopen(pageurl) 12 jsonstr = o.read().replace("null","None").replace("false","False") 13 jsondata = eval(jsonstr) 14 cases = jsondata['data'] 15 for c in cases: 16 vid = c['videoId'] 17 if vid not in videoids: 18 videoids.append(vid) 19 20 print "共有视频%d个" % len(videoids) 21 def shua(url,id): 22 print "视频id:%d" % id 23 try: 24 op = urllib2.urlopen(url,timeout = 2) 25 count = int(op.read()) 26 except Exception as e: 27 print '正在重试...' 28 count = -1 29 finally: 30 if count<1500: 31 if count != -1: 32 print count 33 shua(url,id) 34 35 for v in videoids: 36 counturl = 'http://click.videoincloud.com/count?videoid=%d' % v 37 shua(counturl,v) 38 print "done"