Skip to content

Instantly share code, notes, and snippets.

@kamiheku
Created September 26, 2016 09:32
Show Gist options
  • Save kamiheku/3c3996384441f2a3035985160aa079e6 to your computer and use it in GitHub Desktop.
Save kamiheku/3c3996384441f2a3035985160aa079e6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import requests
import re
import shutil
def download(id):
r = requests.get("http://www.breakbeat-paradise.com/bb_download.php?sampleid={}".format(id))
html = r.text
url = re.search('http://.+\.zip', html).group(0)
filename = url.split('/')[-1]
response = requests.get(url, stream=True)
with open(filename, 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
def getIds(url):
r = requests.get(url)
html = r.text
ids = re.findall("(?<=sampleid=)\d+", html)
return ids
def main():
for id in getIds('http://www.breakbeat-paradise.com/samplesite/bb_drumloops.php'):
print("Downloading pack #{}".format(id))
download(id)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment