j = []
def getList():
url = 'http://10.10.15.15:8109/list?path=%2Fvideo%2F' + clazz + '%2F' + quote(
level) + '%2F' + quote(dir) + '&uid=' + uid + '&sign=' + sign
print(url)
head = {
'user-Agent': 'offcn.cts.client',
'accept-Encoding': 'gzip',
'accept-Language': 'zh-CN,en',
'host': '10.10.15.15:8019'
}
re = requests.get(url, headers=head)
global j
j = json.loads(re.text)
print(re.text)
def spider():
head = {
'User-Agent': 'offcn.cts.client',
'Accept': '/',
'Range': 'bytes=0-',
'Icy-MeteDate': '1',
'accept-Encoding': 'gzip',
'accept-Language': 'zh-CN,en',
'host': '10.10.15.15:8080',
'Referer': 'http://ujiuye.offcn.com'
}
if not os.path.exists(download + "/" + level + "/" + dir):
os.makedirs(download + "/" + level + "/" + dir)
for i in j['filelist']:
name = quote(i['name'])
url = "http://10.10.15.15:8080/video/" + clazz + "/" + level + "/" + dir + "/" + str(
name) + "?auth_key=" + authKey
print("downloading: " + parse.unquote(name))
re = requests.get(url, headers=head)
with open(download + "/" + level + "/" + dir + "/" + i["name"], 'wb') as sf:
sf.write(re.content)
if name == 'main':
with open("conf.json", encoding="utf-8") as f:
data = json.load(f)
uid = data["uid"]
sign = data["sign"]
authKey = data["authKey"]
dir = data["dir"]
level = data["level"]
download = data["download"]
clazz = data["clazz"]
getList()
spider()
for i in j['filelist']的['filelist']和name = quote(i['name'])]的i['name'])]怎么定义?
j类似这样
j={"filelist":["1.txt","2.txt"]}
连里面的数据长啥样都不知道你就能直接取的吗?
这个都是根据最后数据类型的key来取的,比如你的json文件中的key,必须先知道最后的数据类型,然后才能去取