star 一个文件

来源:互联网 发布:团队优化的原则包括 编辑:程序博客网 时间:2024/06/05 08:56
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 sif __name__ == '__main__':    add_starred_files()C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/a8.py{"token": "0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7"}<type 'str'><type 'dict'>0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7Token 0ac9e8585ef6ae51eb62c785d10a6c5102de3ff7p=%2Felk%E7%BD%91%E5%9D%80.txt&repo_id=afd1a8c0-bbd3-4c71-9068-0068585e7d98"success"Process finished with exit code 0

原创粉丝点击