Last active
August 10, 2017 14:25
-
-
Save HakurouKen/d5a7e24dc684d30ad4f804c4e456781d to your computer and use it in GitHub Desktop.
download bilibili p-movie gif.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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