#!/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. GetqueueStatus

    #include "stdafx.h" #include <Windows.h> #include <process.h> #include <ios ...

  2. PHP ~ 原生语法 ~ 根据从数据库查询数据之后快速输出 某个属性的值到 到页面

    一,根据 id 来查询单个的数据 <?php require_once '../../conn.php'; $sql = "select * from blogarticle wher ...

  3. 颜色设置 <color name="white">#FFFFFF</color><!--白色 -->

    <?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...

  4. 201903-1 小中大 Java

    思路: 中位数就是排序后中间的那个数.如果有偶数个数,就是中间两个数的平均值. 注意,这个平均值可能是整数,可能是小数,如果都是一样的处理,如果输出整数是3.0,而不是3,就有问题.所以需要分开处理. ...

  5. Sequence Models Week 1 Building a recurrent neural network - step by step

    Building your Recurrent Neural Network - Step by Step Welcome to Course 5's first assignment! In thi ...

  6. 日志处理中一些shell命令技巧

    日志处理中一些shell命令技巧 阴差阳错的做的日志分析,前途未卜的这段日子,唯一还有点意思的可能就是手动的处理大量日志.总结一下. 日志文件的输入是动则几个G的文本.从N个这样的文件中得到一个列表, ...

  7. C++逐词读取txt

    这一篇来写下std::ifstream读取txt的另一种方式,逐词读取,上一篇是按行读取,逐词读取的话每个单词都以空格或者换行等符号间隔开. 代码如下: #include "stdafx.h ...

  8. 对python里的装饰器

    内裤可以用来遮羞,但是到了冬天它没法为我们防风御寒,聪明的人们发明了长裤,有了长裤后宝宝再也不冷了,装饰器就像我们这里说的长裤,在不影响内裤作用的前提下,给我们的身子提供了保暖的功效. 再回到我们的主 ...

  9. Q4:Median of Two Sorted Arrays

    4. Median of Two Sorted Arrays 官方的链接:4. Median of Two Sorted Arrays Description : There are two sort ...

  10. Android 心跳包心跳连接 如何实现android和服务器长连接呢?推送消息的原理

    前言:现在的大多数移动端应用都有实时得到消息的能力,简单来说,有发送消息的主动权和接受消息的被动权.例如:微信,QQ,天气预报等等,相信好处和用户体验相信大家都知道吧. 提出问题:这种功能必须涉及cl ...