中午写的 细节肯定没做, 就是个大概的流程

登录你的网盘
上传文件(只写了上传到根目录)

就这么个流程刚有兄弟发了个lanzou的在线上传 我也写了个-LMLPHP

话说lanzou登录 密码连个md5都没做 , 被截包密码就明文显示了

刚有兄弟发了个lanzou的在线上传 我也写了个-LMLPHP

  1. import requests, json, os
  2. from lxml import etree
  3. from clint.textui.progress import Bar as ProgressBar
  4. from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
  5. def create_callback(encoder):
  6.     bar = ProgressBar(expected_size=encoder.len, filled_char=’=’)
  7.     def callback(monitor):
  8.         bar.show(monitor.bytes_read)
  9.     return callback
  10. def getFormHash():
  11.     url = "https://pc.woozooo.com/account.php?action=login&ref=/mydisk.php"
  12.     headers = {
  13.         ‘user-agent’: ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36’,
  14.     }
  15.     print("获取formhash中…")
  16.     r = session.get(url, headers=headers)
  17.     html = etree.HTML(r.text)
  18.     formhash = html.xpath(‘//input[@name="formhash"]/@value’)[0]
  19.     print("formhash : %s" % formhash)
  20.     print(‘*’*20)
  21.     return formhash
  22. def login(formhash, username, password):
  23.     print("username = %s, password = %s" % (username, password))
  24.     print("登录中…")
  25.     url = "https://pc.woozooo.com/account.php"
  26.     durl = "https://pc.woozooo.com/mydisk.php"
  27.     headers = {
  28.         ‘content-type’: ‘application/x-www-form-urlencoded’,
  29.         ‘referer’: ‘https://pc.woozooo.com/account.php?action=login&ref=/mydisk.php’,
  30.         ‘user-agent’: ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36’,
  31.     }
  32.     formdata = {
  33.         ‘action’: ‘login’,
  34.         ‘task’: ‘login’,
  35.         ‘ref’: ‘/mydisk.php’,
  36.         ‘formhash’: formhash,
  37.         ‘username’: username,
  38.         ‘password’: password,
  39.     }
  40.     r = session.post(url, data=formdata, headers=headers)
  41.     r = session.get(durl)
  42.     keyword = "mydisk.php?item=files&action=index&u=" + username
  43.     if keyword in r.text:
  44.         print("登录成功…")
  45.     else:
  46.         exit("登录出错, 退出程序!")
  47.     print(‘*’*20)
  48. def uploadFile(file):
  49.     print("上传文件中…")
  50.     fileName = os.path.split(file)[1]
  51.     api = "https://pc.woozooo.com/fileup.php"
  52.     headers = {
  53.         ‘user-agent’: ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36’,
  54.     }
  55.     formdata = {
  56.         ‘task’: ‘1’,
  57.         ‘folder_id’: ‘-1’,
  58.         ‘type’: ‘application/octet-stream’,
  59.         ‘upload_file’: (fileName,open(file, ‘rb’), ‘application/octet-stream’)
  60.     }
  61.     encoder = MultipartEncoder(formdata)
  62.     callback = create_callback(encoder)
  63.     monitor = MultipartEncoderMonitor(encoder, callback)
  64.     headers[‘Content-Type’] = monitor.content_type
  65.     r = session.post(api, data=monitor, headers=headers)
  66.     print(‘\nUpload finished! (Returned status {0} {1})’.format(
  67.         r.status_code, r.reason
  68.     ))
  69.     print(json.loads(r.text))
  70.     print(‘*’*20)
  71. if __name__ == "__main__":
  72.     config = {
  73.         ‘username’: ‘用户名’,
  74.         ‘password’: ‘密码’,
  75.     }
  76.     session = requests.session()
  77.     login(getFormHash(), **config)
  78.     fileList = [‘D:\备份\phpStudy.zip’, ‘D:\备份\WinSCP.rar’]
  79.     for file in fileList:
  80.         uploadFile(file)

复制代码

安徽网友:那是没https
浙江网友:不错不错,python还是方便啊

01-20 10:10