So I am trying to make a post request to a certain website where the request’s data has an image, I looked at their source and they do the following:
they first ask you to input the image file using an input element
<input type="file" id="iconImageFile" accept="image/*" name="iconImageFile"/>
then they make a request and send the file
var r = new FormData;
r.append("iconImageFile", $("#iconImageFile")[0].files[0]),
$.ajax({
url: url,
type: "POST",
data: r,
cache: !1,
contentType: !1,
processData: !1
})
My question is how would I be able to replicate such a request using python’s requests library? I already have all of the headers needed for verification, I am just confused on how I would send this image in the request.
session.post(url,data = {
'iconImageFile' : open('icon.png', encoding="utf8", errors='ignore')
})
Any help would be appreciated 😀