python 模拟创建seafile 目录 *** 作示例

python 模拟创建seafile 目录 *** 作示例,第1张

概述python 模拟创建seafile 目录 *** 作示例 本文实例讲述了python 模拟创建seafile 目录 *** 作.分享给大家供大家参考,具体如下: # !/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 import urllib import cookielib import json import httplib import re import requests import StringIO import time import sys import json impor

本文实例讲述了python 模拟创建seafile 目录 *** 作。分享给大家供大家参考,具体如下:

# !/usr/bin/env python# -*- Coding: utf-8 -*-import urllib2import urllibimport cookielibimport Jsonimport httplibimport reimport requestsimport StringIOimport timeimport sysimport Jsonimport res = requests.session()username='[email protected]'password='newja01'myurl='http://10.4.48.2:8000/accounts/login?next=/'headers = {  'User-Agent': 'Mozilla/5.0 (windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 firefox/54.0'   }response = s.get(myurl,headers=headers,timeout=10)a= response.content#<form action="" method="post" ><input type='hIDden' name='csrfmIDdlewaretoken' value='ZWnUDf5XVX0kagjIoJLKyU8UdO8KBGFn' />#p=re.compile('.*?<token>(.*?)</token>*')p=re.compile('.*<form.*value=\'(.*?)\'.*\s+/>',flags=re.S)m=p.match(a)print mtoken= m.group(1)print tokenmyurl='http://10.4.48.2:8000/accounts/login/?next=/'headers = {  'User-Agent': 'Mozilla/5.0 (windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 firefox/54.0'   }data={'csrfmIDdlewaretoken':token,'login':username,'password':password,'next':'/'}response = s.post(myurl,data=data,timeout=10)print response.contentu1='http://10.4.48.2:8000/API2/repos/?type=mine&_=1553493865054'a= s.get(u1).contentprint aprint type(a)b=Json.loads(a)print bprint type(b)for i in range(len(b)):  print str(b[i]).decode('unicode-escape')##创建目录u2='http://10.4.48.2:8000/API2/repos/?from=web'headers = {  'User-Agent': 'Mozilla/5.0 (windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 firefox/54.0','X-CSrftoken':token,'Content-Type':'application/Json;charset=utf-8'   }data={"name":"perl","encrypted":"false","passwd1":"","passwd2":"","passwd":"","ID":"null","desc":"","mtime":0,"mtime_relative":"","owner":"-","owner_nickname":"-"}response = s.post(u2,data=Json.dumps(data),timeout=10)print response.content

更多关于Python相关内容感兴趣的读者可查看本站专题:《Python文件与目录 *** 作技巧汇总》、《Python文本文件 *** 作技巧汇总》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串 *** 作技巧汇总》及《Python入门与进阶经典教程》

希望本文所述对大家Python程序设计有所帮助。

总结

以上是内存溢出为你收集整理的python 模拟创建seafile 目录 *** 作示例全部内容,希望文章能够帮你解决python 模拟创建seafile 目录 *** 作示例所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1199759.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-04
下一篇 2022-06-04

发表评论

登录后才能评论

评论列表(0条)

保存