Skip to content

Instantly share code, notes, and snippets.

@HakurouKen
Last active August 10, 2017 14:25
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 HakurouKen/d5a7e24dc684d30ad4f804c4e456781d to your computer and use it in GitHub Desktop.
Save HakurouKen/d5a7e24dc684d30ad4f804c4e456781d to your computer and use it in GitHub Desktop.
download bilibili p-movie gif.
#! /usr/bin/python
# -*- coding: utf-8 -*-
import requests
import os
URL = 'http://www.bilibili.com/index/index-icon.json'
def get():
resp = requests.get(URL)
arr = resp.json().get('fix',[])
return [{
'name': data["title"] + get_ext(data["icon"]),
'url': 'http:' + data["icon"]
} for data in arr]
def get_ext(filepath):
return os.path.splitext(filepath)[1]
def download():
all_data = get()
if not os.path.isdir('icons'):
os.mkdir('icons')
for data in all_data:
print u'downloading {}, url: {}'.format(data['name'],data['url'])
with open(u'icons/{}'.format(data['name']),'wb') as f:
f.write(requests.get(data['url']).content)
if __name__ == '__main__':
download()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment