標籤:tool ora ext 名稱 mini pytho loop 網頁 視頻下載
主要分為三部分:1.整體要實現的功能。2.貼出程式原始碼及exe程式貼圖3.各個資源
第一、整體要實現的功能
1.根據url地址,擷取課程視頻地址
2.增加圖形化介面
3.將python程式,發布為exe檔案,這樣大家不安裝python就可以運行了
4.由於下載檔案名稱字並不是課程名字,所以下載後要能夠實現批量重新命名(目前1.0版本未實現)
第二、程式原始碼及exe程式貼圖
1.程式原始碼:down163openv1.0.py
1 #coding:utf-8 2 import urllib 3 from bs4 import BeautifulSoup 4 import chardet 5 import os 6 import pickle 7 import wx 8 def getdownLoadInfo(url): 9 #課程名10 courseTitle=‘‘11 #課程數目12 courseCount=013 #可下載視頻數目14 videoCount=015 #視頻16 videoUrl=[]17 #讀取網頁源檔案到html,並處理後存入soup18 rawhtml=urllib.urlopen(url).read()19 htmlencoding=chardet.detect(rawhtml)[‘encoding‘]20 html=rawhtml.decode(htmlencoding,‘ignore‘).encode(‘utf-8‘)21 soup=BeautifulSoup(html)22 #對soup進行分析23 courseTitle=soup.find(name=‘title‘).contents[0]24 courseInfo=soup.find(attrs={"id":"list2"})25 courseTitleInfo=courseInfo.find_all(attrs={"class":"u-ctitle"})26 courseVideoInfo=courseInfo.find_all(attrs={"class":"u-cdown"}) 27 for content in courseTitleInfo:28 courseCount=courseCount+1 29 for link in courseVideoInfo:30 href=link.find(attrs={"class":"downbtn"})31 if type(href)==type(None):32 pass33 else:34 href=link.find(attrs={"class":"downbtn"}).get("href")35 videoCount=videoCount+136 videoUrl.append(href)37 return courseTitle,courseCount,videoCount,videoUrl 38 39 def showInfo(event):40 # url=r"http://v.163.com/special/opencourse/algorithms.html"41 textArea.SetValue("")42 url=text.GetValue()43 courseTitle,courseCount,videoCount,videoUrl=getdownLoadInfo(url)44 labelInfo.SetLabel(u‘課程名稱:‘+courseTitle+‘\n‘+u‘,課程總集數:‘+unicode(courseCount)+‘\n‘+u‘,可下載集數:‘+unicode(videoCount))45 for value in videoUrl:46 textArea.AppendText(value+‘\n‘)47 if __name__==‘__main__‘:48 #建立APP49 app=wx.App(False)50 #建立frame視窗51 frame=wx.Frame(parent=None,title=u‘下載網易公開課v1.0‘,size=(800,600),style=wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX)52 frame.Center()53 #建立Menu54 menuBar=wx.MenuBar()55 menu1=wx.Menu()56 menuBar.Append(menu1,u"檔案")57 #建立工具列58 toolbar=frame.CreateToolBar()59 #建立Panel60 panel=wx.Panel(frame)61 panel.SetBackgroundColour(‘white‘)62 63 label=wx.StaticText(panel,label=u‘請輸入公開課地址:‘)64 font=wx.Font(13,wx.DECORATIVE,wx.NORMAL,wx.NORMAL)65 label.SetFont(font)66 67 text=wx.TextCtrl(panel,size=(700,-1))68 69 button=wx.Button(panel,label=u‘提取‘)70 button.SetFont(font)71 frame.Bind(wx.EVT_BUTTON,showInfo, button)72 labelInfo=wx.StaticText(panel,size=(-1,50))73 textArea=wx.TextCtrl(panel,style=wx.TE_MULTILINE,size=(700,300))74 #用sizer控制介面75 sizer=wx.FlexGridSizer(cols=1,vgap=10)76 sizer.AddMany([label,text,button,labelInfo,textArea])77 panel.SetSizer(sizer)78 79 # #建立狀態列80 statusBar=frame.CreateStatusBar()81 82 frame.Show(True)83 app.MainLoop()
2.exe程式貼圖:
第三、各個資源:(用的360網盤)
1.原始碼:
http://pan.baidu.com/s/1sjuID5b
2.綠色版軟體(exe):
http://pan.baidu.com/s/1nt9JPkH
3.各個擴充包:
http://pan.baidu.com/s/1nt5akjv
(完)
用python打造網易公開課視頻下載軟體