Created
February 8, 2014 18:16
-
-
Save ly0/8887780 to your computer and use it in GitHub Desktop.
百度网盘api范例 遍历网盘
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
import json | |
from baidupcsapi import PCS | |
pcs = PCS('username','password') | |
def walk(path, tabs=0): | |
print '\t'*tabs+path | |
files = json.loads(pcs.list_files(path).content)['list'] | |
for file in files: | |
if file['isdir'] == 1: | |
walk(file['path'],tabs=tabs+1) | |
else: | |
print '\t'*(tabs+1)+file['server_filename'] | |
walk('/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment