32 lines
470 B
Python
32 lines
470 B
Python
|
# /bin/python2
|
||
|
|
||
|
import mechanize
|
||
|
from time import sleep
|
||
|
|
||
|
br = mechanize.Browser()
|
||
|
|
||
|
# url here
|
||
|
br.open('')
|
||
|
|
||
|
# file type here
|
||
|
filetypes = ['.ogg', '.mp3']
|
||
|
my_files = []
|
||
|
|
||
|
for l in br.links():
|
||
|
for t in filetypes:
|
||
|
if t in str(l):
|
||
|
my_files.append(l)
|
||
|
|
||
|
|
||
|
def download_link(l):
|
||
|
f = open(l.text, 'w')
|
||
|
br.click_link(l)
|
||
|
f.write(br.response().read())
|
||
|
print(l.text, "has been downloaded")
|
||
|
|
||
|
for l in my_files:
|
||
|
sleep(1)
|
||
|
download_link(l)
|
||
|
|
||
|
|