python获取Stanford AI课程的批量下载地址

## obtain the download uri of the AI lessons from udacity

from BrowserShadow import BrowserShadow
import json

content_list_page_url = ' https://www.udacity.com/api/nodes?depth=1&keys%5B%5D=cs271&projection=dashboard&required_behavior=view'
brw = BrowserShadow()
res = brw.open_url(content_list_page_url)
page_content = res.read().decode().replace(")]}'",'')


response_json = json.loads(page_content);
lesson_node = response_json['references']['Node']
lesson_keys = lesson_node.keys()
for one_lesson_key in lesson_keys:
    one_lesson_json = response_json['references']['Node'][one_lesson_key]
    lesson_archive_uri = one_lesson_json['_video_zip_archive']['_cdn_reference']['uri']
    print(lesson_archive_uri)

问题1:在对网页的源码进行分析的过程中发现,web页面显示出来的额东西,居然在网页源代码中没有,所以不能直接解析网页源码来获取uri地址了
思路:这种情况下应该是web利用了ajax进行了异步调用,后面动态添加的内容
方案:查找ajax调用请求的uri进行直接内容获取,通过chrome调用跟踪请求地址情况,发现了内容调用地址
        直接对地址进行访问,返回的是json数据,对json数据解析获得资源对应的uri地址,ko!!!

ps:
(1)、Stanford AI入门课程下载地址
http://zips.udacity-data.com/48734405/11.%20HMMs%20and%20Filters%20Videos.zip
http://zips.udacity-data.com/48741162/9.%20Planning%20under%20Uncertainty%20Videos.zip
http://zips.udacity-data.com/48641663/21.%20Natural%20Language%20Processing%20Videos.zip
http://zips.udacity-data.com/48624746/3.%20Probability%20in%20AI%20Videos.zip
http://zips.udacity-data.com/48716317/14.%20Game%20Theory%20Videos.zip
http://zips.udacity-data.com/48696615/6.%20Unsupervised%20Learning%20Videos.zip
http://zips.udacity-data.com/48652575/18.%20Computer%20Vision%20III%20Videos.zip
http://zips.udacity-data.com/48744101/Problem%20Set%203%20Videos.zip
http://zips.udacity-data.com/48727637/Problem%20Set%204%20Videos.zip
http://zips.udacity-data.com/48720299/13.%20Games%20Videos.zip
http://zips.udacity-data.com/48634857/Problem%20Set%206%20Videos.zip
http://zips.udacity-data.com/48738190/8.%20Planning%20Videos.zip
http://zips.udacity-data.com/48641664/Problem%20Set%208%20Videos.zip
http://zips.udacity-data.com/48735172/12.%20MDP%20Review%20Videos.zip
http://zips.udacity-data.com/48688925/1.%20Welcome%20to%20AI%20Videos.zip
http://zips.udacity-data.com/48632887/Problem%20Set%201%20Videos.zip
http://zips.udacity-data.com/cs271/Intro%20to%20Artificial%20Intelligence%20Videos.zip
http://zips.udacity-data.com/48635748/7.%20Representation%20with%20Logic%20Videos.zip
http://zips.udacity-data.com/48743135/20.%20Robotics%20II%20Videos.zip
http://zips.udacity-data.com/48712412/Problem%20Set%202%20Videos.zip
http://zips.udacity-data.com/48678875/2.%20Problem%20Solving%20Videos.zip
http://zips.udacity-data.com/48734403/22.%20Natural%20Language%20Processing%20II%20Videos.zip
http://zips.udacity-data.com/48734415/Problem%20Set%207%20Videos.zip
http://zips.udacity-data.com/48745108/Midterm%20Exam%20Videos.zip
http://zips.udacity-data.com/48743138/4.%20Probabilistic%20Inference%20Videos.zip
http://zips.udacity-data.com/48641661/15.%20Advanced%20Planning%20Videos.zip
http://zips.udacity-data.com/48673757/19.%20Robotics%20I%20Videos.zip
http://zips.udacity-data.com/48634869/17.%20Computer%20Vision%20II%20Videos.zip
http://zips.udacity-data.com/48703335/5.%20Machine%20Learning%20Videos.zip
http://zips.udacity-data.com/48734412/Problem%20Set%205%20Videos.zip
http://zips.udacity-data.com/48691664/Office%20Hours%20Videos.zip
http://zips.udacity-data.com/48724471/10.%20Reinforcement%20Learning%20Videos.zip
http://zips.udacity-data.com/48738189/Final%20Assessment%20Videos.zip
http://zips.udacity-data.com/48739337/16.%20Computer%20Vision%20I%20Videos.zip

(2)字幕地址
http://zips.udacity-data.com/48734405/11.%20HMMs%20and%20Filters%20Subtitles.zip
http://zips.udacity-data.com/48741162/9.%20Planning%20under%20Uncertainty%20Subtitles.zip
http://zips.udacity-data.com/48641663/21.%20Natural%20Language%20Processing%20Subtitles.zip
http://zips.udacity-data.com/48624746/3.%20Probability%20in%20AI%20Subtitles.zip
http://zips.udacity-data.com/48716317/14.%20Game%20Theory%20Subtitles.zip
http://zips.udacity-data.com/48696615/6.%20Unsupervised%20Learning%20Subtitles.zip
http://zips.udacity-data.com/48652575/18.%20Computer%20Vision%20III%20Subtitles.zip
http://zips.udacity-data.com/48744101/Problem%20Set%203%20Subtitles.zip
http://zips.udacity-data.com/48727637/Problem%20Set%204%20Subtitles.zip
http://zips.udacity-data.com/48720299/13.%20Games%20Subtitles.zip
http://zips.udacity-data.com/48634857/Problem%20Set%206%20Subtitles.zip
http://zips.udacity-data.com/48738190/8.%20Planning%20Subtitles.zip
http://zips.udacity-data.com/48641664/Problem%20Set%208%20Subtitles.zip
http://zips.udacity-data.com/48735172/12.%20MDP%20Review%20Subtitles.zip
http://zips.udacity-data.com/48688925/1.%20Welcome%20to%20AI%20Subtitles.zip
http://zips.udacity-data.com/48632887/Problem%20Set%201%20Subtitles.zip
http://zips.udacity-data.com/cs271/Intro%20to%20Artificial%20Intelligence%20Subtitles.zip
http://zips.udacity-data.com/48635748/7.%20Representation%20with%20Logic%20Subtitles.zip
http://zips.udacity-data.com/48743135/20.%20Robotics%20II%20Subtitles.zip
http://zips.udacity-data.com/48712412/Problem%20Set%202%20Subtitles.zip
http://zips.udacity-data.com/48678875/2.%20Problem%20Solving%20Subtitles.zip
http://zips.udacity-data.com/48734403/22.%20Natural%20Language%20Processing%20II%20Subtitles.zip
http://zips.udacity-data.com/48734415/Problem%20Set%207%20Subtitles.zip
http://zips.udacity-data.com/48745108/Midterm%20Exam%20Subtitles.zip
http://zips.udacity-data.com/48743138/4.%20Probabilistic%20Inference%20Subtitles.zip
http://zips.udacity-data.com/48641661/15.%20Advanced%20Planning%20Subtitles.zip
http://zips.udacity-data.com/48673757/19.%20Robotics%20I%20Subtitles.zip
http://zips.udacity-data.com/48634869/17.%20Computer%20Vision%20II%20Subtitles.zip
http://zips.udacity-data.com/48703335/5.%20Machine%20Learning%20Subtitles.zip
http://zips.udacity-data.com/48734412/Problem%20Set%205%20Subtitles.zip
http://zips.udacity-data.com/48691664/Office%20Hours%20Subtitles.zip
http://zips.udacity-data.com/48724471/10.%20Reinforcement%20Learning%20Subtitles.zip
http://zips.udacity-data.com/48738189/Final%20Assessment%20Subtitles.zip
http://zips.udacity-data.com/48739337/16.%20Computer%20Vision%20I%20Subtitles.zip
把地址挂到迅雷就ok了,下载中。。。

你可能感兴趣的:(网络,python)