#!/usr/bin/env python
# coding=utf-8 import urllib
import urllib2
import cookielib def setcookie(enable_proxy=False):
proxy_handler = urllib2.ProxyHandler({"http":'10.13.61.118:6666', "https":'10.13.61.118:6666'}) # 学校代理
cookiejar = cookielib.LWPCookieJar()
cookie_support = urllib2.HTTPCookieProcessor(cookiejar)
debug_hander = urllib2.HTTPHandler(debuglevel=1) # debuglevel=0
if enable_proxy:
opener = urllib2.build_opener(cookie_support, proxy_handler, debug_hander)
else:
opener = urllib2.build_opener(cookie_support, debug_hander)
urllib2.install_opener(opener) def download(fp,tofile):
outf = open(tofile,'wb')
c = 0
print ('Downloading to %s'%(tofile))
while True:
s = fp.read(1024*128)
if len(s) == 0:
break
outf.write(s)
c += len(s)
print ('Download %d'%(c))
outf.close() import os
def main(num=32, urlhost='https://class.coursera.org/ml-006/lecture/download.mp4?lecture_id='):
for i in xrange(1,num+1):
if os.path.exists(str(i)+'.mp4'):continue
print urlhost+str(i) header = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0',
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language':'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3',
'Accept-Encoding':'gzip, deflate, sdcn',
}
req = urllib2.Request(url=urlhost+str(i), headers=header)
try:
fp = urllib2.urlopen(req)
except:
continue
download(fp, str(i)+'.mp4')
fp.close() if __name__ == '__main__':
setcookie()
main(106, 'https://class.coursera.org/pgm/lecture/download.mp4?lecture_id=')

coursera课程视频的更多相关文章

  1. 无责任共享 Coursera、Udacity 等课程视频

    本文转载自网络,原作者不详. (本文是用 markdown 写的,访问 https://www.zybuluo.com/illuz/note/71868 获得更佳体验) 程序语言 interactiv ...

  2. Coursera课程下载和存档计划[转载]

    上周三收到Coursera平台的群发邮件,大意是Coursera将在6月30号彻底关闭旧的课程平台,全面升级到新的课程平台上,一些旧的课程资源(课程视频.课程资料)将不再保存,如果你之前学习过相关的课 ...

  3. 【DeepLearning学习笔记】Coursera课程《Neural Networks and Deep Learning》——Week2 Neural Networks Basics课堂笔记

    Coursera课程<Neural Networks and Deep Learning> deeplearning.ai Week2 Neural Networks Basics 2.1 ...

  4. 第一次使用博客及Coursera课程体验

    前言: 第一天的学习目标有三个 开设博客园账户 开设Github账号 进行第一次coursera课程学习:Internet History, Technology, and Security  (网址 ...

  5. 第三百七十四节,Django+Xadmin打造上线标准的在线教育平台—创建课程app,在models.py文件生成4张表,课程表、课程章节表、课程视频表、课程资源表

    第三百七十四节,Django+Xadmin打造上线标准的在线教育平台—创建课程app,在models.py文件生成4张表,课程表.课程章节表.课程视频表.课程资源表 创建名称为app_courses的 ...

  6. 【网页开发学习】Coursera课程《面向 Web 开发者的 HTML、CSS 与 Javascript》Week1课堂笔记

    Coursera课程<面向 Web 开发者的 HTML.CSS 与 Javascript> Johns Hopkins University Yaakov Chaikin Week1 In ...

  7. mxonline实战12, 课程评论,相关课程推荐,课程视频页

    对应github地址:第12天   一. 课程评论   1. 创建URL, VIEW courses/views.py -> Course

  8. 【Python学习笔记】Coursera课程《Using Databases with Python》 密歇根大学 Charles Severance——Week4 Many-to-Many Relationships in SQL课堂笔记

    Coursera课程<Using Databases with Python> 密歇根大学 Week4 Many-to-Many Relationships in SQL 15.8 Man ...

  9. 【Python学习笔记】Coursera课程《Using Python to Access Web Data》 密歇根大学 Charles Severance——Week6 JSON and the REST Architecture课堂笔记

    Coursera课程<Using Python to Access Web Data> 密歇根大学 Week6 JSON and the REST Architecture 13.5 Ja ...

随机推荐

  1. 【LeetCode】最小路径和

    [问题]给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小. 说明:每次只能向下或者向右移动一步. 示例: 输入: [ [,,], [,,], [, ...

  2. unique constraint(PD.HSI_RIGHT) violated

    插入时报错,原因:唯一约束重复了.... 查看表中有唯一约束的列是不是已经有值了 果然,唯一约束有两条重复的记录. ------------------------------------------ ...

  3. Loadrunner安装与破解

    一.安装loadrunner 1. 点击setup.exe 2. 点击安装完整程序 3. 点击确定,安装必需程序 4. 安装vc2005的时候报了如下错,导致无法继续安装,没有报错可跳过第五步 5. ...

  4. 第三章,数据和C

    3.1 数据类型关键字 位:计算机内部数据存储的最小存储单位(bit). 字节:计算机中数据处理的基本单位(Byte)),1B=8bit. 字:计算机进行数据处理时,一次存取,加工和传送的数据长度.( ...

  5. 实验吧Web-易-天网管理系统(php弱类型,==号)

    打开网页,查看源码,看到 <!-- $test=$_GET['username']; $test=md5($test); if($test=='0') --> 说明用户名需要加密之后为0. ...

  6. map构造同时初始化

    Map<String, Object> mtest =  new HashMap<String, Object>(){{put("test","M ...

  7. 深入浅出Python装饰器

    1.前言 装饰器是Python的特有的语法,刚接触装饰器的同学可能会觉得装饰器很难理解,装饰器的功能也可以不用装饰器实现,但是装饰器无疑是提高你Python代码质量的利器(尤其是使用在一些具有重复功能 ...

  8. 在linux上部署多个tomcat

    1.vim  /etc/profile ##########first tomcat########### CATALINA_BASE=/usr/apache-tomcat--fore CATALIN ...

  9. 解决configure: error: C++ compiler cannot create executables问题

    参考 yum install gcc gcc++ 呵呵,这样的话还是有组件没有安装完整的.再执行一下这个命令就可以解决问题. yum install gcc gcc-c++ gcc-g77

  10. ci框架与smarty的整合

    ci框架与smarty的整合 来源:未知    时间:2014-10-20 11:38   阅读数:108   作者:xbdadmin [导读] Ci 和 smarty 的完美结合 Ci 结合 sma ...