Skip to content

Instantly share code, notes, and snippets.

@sfantree
Created October 22, 2016 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfantree/c5494a3963d1397aedbb86c7381ed5a2 to your computer and use it in GitHub Desktop.
Save sfantree/c5494a3963d1397aedbb86c7381ed5a2 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import re
import urllib
def getHtml(url):
page=urllib.urlopen(url)
html=page.read()
return html
def getMp4(html):
r=r"href='(http.*\.mp4)'"
re_mp4=re.compile(r)
mp4List=re.findall(re_mp4,html)
filename=1
for mp4url in mp4List:
urllib.urlretrieve(mp4url,"%s.mp4" %filename)
print 'file "%s.mp4" done' %filename
filename+=1
url=raw_input("please input the source url:")
html=getHtml(url)
getMp4(html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment