• star 一个文件


    star A File:
    
    curl -v -d "repo_id=dae8cecc-2359-4d33-aa42-01b7846c4b32&p=/foo.md" -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/starredfiles/
    
    def add_starred_files():
        token = gettoken()
        token = 'Token' + ' '+ token
        print token
        data = {'repo_id': 'afd1a8c0-bbd3-4c71-9068-0068585e7d98', 'p': '/elk网址.txt'}
        post_data = urllib.urlencode(data)  # 将post消息化成可以让服务器编码的方式
        print post_data
        cj = cookielib.CookieJar()  # 获取cookiejar实例
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        # 自己设置User-Agent(可用于伪造获取,防止某些网站防ip注入)
        headers = {"Authorization": token, "Accept": "application/json; indent=4", "content-type": "application/x-www-form-urlencoded"}
        website = 'http://127.0.0.1:8000/api2/starredfiles/'
        req = urllib2.Request(website, post_data, headers)
        content = opener.open(req)
        s = content.read()  # linux下没有gbk编码,只有utf-8编码
        print s
    if __name__ == '__main__':
        add_starred_files()
    
    
    C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/a8.py
    {"token": "0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7"}
    <type 'str'>
    <type 'dict'>
    0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7
    Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7
    p=%2Felk%E7%BD%91%E5%9D%80.txt&repo_id=afd1a8c0-bbd3-4c71-9068-0068585e7d98
    "success"
    
    Process finished with exit code 0

  • 相关阅读:
    SQL 大数据查询如何进行优化?
    事件和委托的区别
    虚方法(virtual)和抽象方法(abstract)的和接口(interface)的区别
    高并发的秒杀
    C#算法
    口试C#概念
    口试Linq题
    口试大数据及大并发问题
    Windows下MongoDB安装
    MongoDB简单介绍
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349578.html
Copyright © 2020-2023  润新知