|
|
完整的代码 填上cookie 和转存目标的文件夹ID
import requests
import hjson
import urllib.parse
import json
import time
def _main():
h = {
"Cookie": "COOKIE_LOGIN_USER=<token>"
}
total = 1
for pp in range(1,3):
req = requests.get(
'https://cloud.189.cn/v2/listPublicShare.action?userId=330783715&mediaType=0&orderBy=filename&order=ASC&pageNum=%s&pageSize=545' % pp
, headers=h)
j = hjson.loads(req.content.decode())
for a in j['data']:
print('%s/%s' % (total,1081))
id = a["fileId"]
name = str(a["fileName"])
sid = a["shareId"]
fo = a["isFolder"]
t = [{"fileId": id, "fileName": name, "isFolder": 1 if fo else 0}]
jdata = json.dumps(t, ensure_ascii=False).replace(' ','')
data = ''
data += 'type=SHARE_SAVE'
data += '&taskInfos=' + str(urllib.parse.quote(jdata))
data += '&targetFolderId=<要转存到的你自己的文件夹的ID>'
data += '&shareId=' + str(sid)
ih = h
ih['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
resp = requests.post('https://cloud.189.cn/createBatchTask.action', headers=ih, data=data)
print(name, resp.content.decode())
total +=1
time.sleep(0.5)
if __name__ == '__main__':
_main() |
|