欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python 模擬創(chuàng)建seafile 目錄操作示例

 更新時(shí)間:2019年09月26日 10:23:11   作者:zhaoyangjian724  
這篇文章主要介紹了python 模擬創(chuàng)建seafile 目錄操作,結(jié)合實(shí)例形式詳細(xì)分析了Python模擬創(chuàng)建seafile 目錄相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了python 模擬創(chuàng)建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
import re
s = requests.session()
username='015208@zjtlcb.com'
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" class="con"><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 m
token= m.group(1)
print token
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'
   }
data={'csrfmiddlewaretoken':token,'login':username,'password':password,'next':'/'}
response = s.post(myurl, data=data, headers=headers,timeout=10)
print response.content
u1='http://10.4.48.2:8000/api2/repos/?type=mine&_=1553493865054'
a= s.get(u1).content
print a
print type(a)
b=json.loads(a)
print b
print type(b)
for i in range(len(b)):
  print str(b[i]).decode('unicode-escape')
##創(chuàng)建目錄
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), headers=headers,timeout=10)
print response.content

更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python文件與目錄操作技巧匯總》、《Python文本文件操作技巧匯總》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進(jìn)階經(jīng)典教程

希望本文所述對大家Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論