저는 며칠 동안 주변을 둘러 보았습니다.이를 이해할 수 없습니다. 기본적으로 서버에 이미지를 업로드하고 대가로 ID를 가져 오는 중이므로 문제는이 ID를 추출하여 데이터베이스에 저장할 준비가 된 문자열로 변경하는 방법을 알 수 없다는 것입니다. 여기 Python 요청 - response.text에서 데이터 추출
프로그램 코드
url = <Server address>
with open("image.jpg", "rb") as image_file:
files = {'file': image_file}
auth = ('<Key>', '<Pass>')
r = requests.post(url, files=files, auth=auth)
data = r.json()
uploaded = data.get('uploaded')
content_id = uploaded[0]
print r
print r.text
print '--------------'
print str(content_id)
그리고
난 당신이 JSON을 받고있는<Response [200]>
{
"status": "success",
"uploaded": [
{
"filename": "image.jpg",
"id": "6476edfa1d262ad81181d992da78149d"
}
]
}
--------------
{u'id': u'6476edfa1d262ad81181d992da78149d', u'filename': u'image.jpg'}
content_id [ 'id']'? – Maroun