Advertisement
Guest User

Mixcloud Profile Scraper

a guest
Oct 5th, 2019
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import requests, json, sys
  2.  
  3. if len(sys.argv) != 2:
  4.     print("Please specify a mixcloud account name to grab all Cloudcast links: mget.py keepingtheravealive")
  5.     sys.exit()
  6.    
  7. r = requests.get("https://api.mixcloud.com/" + sys.argv[1] + "/cloudcasts/")
  8. json_r = json.loads(r.text)
  9. full_list = []
  10.  
  11. if 'data' not in json_r:
  12.     print("The username was not found or the user does not have any 'shows' on their profile")
  13.     sys.exit()
  14.  
  15. while True:
  16.     for i in range(0, len(json_r["data"])):
  17.         full_list.append("https://mixcloud.com"+json_r["data"][i]["key"])
  18.     if 'next' not in json_r["paging"]: break
  19.     r = requests.get(json_r["paging"]["next"])
  20.     json_r = json.loads(r.text)
  21.    
  22. with open('mc_list_'+sys.argv[1], 'w') as f:
  23.     for item in full_list:
  24.         f.write("%s\n" % item)
  25.        
  26. print("Found "+str(len(full_list)) + " links for user \""+sys.argv[1]+"\". All links are in the file mc_list_"+sys.argv[1])
  27. print("Use this list with youtube-dl and the parameter -a mc_list_"+sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement