Guest User

thesimsresource dl

a guest
Jan 23rd, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import requests
  4. import sys
  5. import re
  6.  
  7. def download_package(id, path=""):
  8.     link = "https://thesimsresource.com/ajax.php?c=downloads&a=getdownloadurl&ajax=1&itemid={}&mid=0&lk=0"
  9.     # print(link.format(id))
  10.     res = requests.get(link.format(id)).json()
  11.     dl_link = res['url']
  12.     file = requests.get(dl_link)
  13.     fname = re.findall("filename=\"(.+)\"", file.headers['content-disposition'])[0]
  14.     print(fname)
  15.     with open(path + fname, 'wb') as f:
  16.         f.write(file.content)
  17.  
  18. if __name__ == "__main__":
  19.     download_package(sys.argv[1], "dl/")
Advertisement
Add Comment
Please, Sign In to add comment