我尝试使用此网址上传pcloud(https://api.pcloud.com/uploadfile?)文件:
https://api.pcloud.com/uploadfile?username=myemail&password=mypassword&path=/&filename=myfile
但是我收到以下错误:
import requests
import json
username = 'test@gmail.com'
password = 'mypassword'
myfile = r'd:\MUSIC\Get Lucky\01 - Border Reiver.mp3'
url = "https://api.pcloud.com/uploadfile?username=%s&password=%s&path=/&filename=%s" % (username, password, myfile)
get = requests.get(url)
print json.loads(get.text)
这是我在Windows上的示例代码:
.nav {
width: 80%;
border: 5px solid;
margin-top: 35%;
margin-left: 10%;
padding-left: 2%;
}
.links {
padding-left: 15%;
padding-top: 5%;
}
.col-md-8 {
border: 5px solid;
}
.col-md-4 {
border: 5px solid;
}
.video-container iframe {
position: absolute;
margin-top: 10%;
left: 0;
width: 100%;
height: 50%;
}
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 35px;
height: 0;
overflow: hidden;
}
答案 0 :(得分:0)
您的代码需要一个带有 Keep-Alive 标头的POST。
import requests
session = requests.Session()
files = {'01 - Border Reiver.mp3': open('d:\MUSIC\Get Lucky\01 - Border Reiver.mp3', 'rb')}
data = {'username': 'test@gmail.com', 'password': 'mypassword'}
post = session.POST('https://api.pcloud.com/uploadfile', files=files, data=data)
print(post.json())
有关更详细的示例,您可以查看pcloud API的Python包装器。它可以在PyPi和github上使用。 https://pypi.python.org/pypi/pcloud