S
S
stvoid2018-10-13 13:23:40
Django
stvoid, 2018-10-13 13:23:40

How to form multipart/form-data correctly?

I can’t correctly form the form for sending a post in python 3.
An example of a form that leaves through the browser (looked in firefox):

spoiler
-----------------------------157103252818570
Content-Disposition: form-data; name="next"
https://WEBSITE/jobgroup/21093/
-----------------------------157103252818570
Content-Disposition: form-data; name="csrfmiddlewaretoken"
c7fHIx9J7ARsv6ytKGz6iROHffAHKhXv
-----------------------------157103252818570
Content-Disposition: form-data; name="e-store_0"
Молком
-----------------------------157103252818570
Content-Disposition: form-data; name="e-store_1"
142
-----------------------------157103252818570
Content-Disposition: form-data; name="e-date_for_job"
20.10.2018 00:00
-----------------------------157103252818570
Content-Disposition: form-data; name="e-description"
какое то описание
-----------------------------157103252818570
Content-Disposition: form-data; name="e-specific"
101
-----------------------------157103252818570
Content-Disposition: form-data; name="e-boss_region_0"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-boss_region_1"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-emails"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-date_comp_job"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-attachment"; filename=""
Content-Type: application/octet-stream
-----------------------------157103252818570
Content-Disposition: form-data; name="e-status"
N
-----------------------------157103252818570
Content-Disposition: form-data; name="e-rating"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-show_client"
on
-----------------------------157103252818570
Content-Disposition: form-data; name="e-show_remark"
on
-----------------------------157103252818570
Content-Disposition: form-data; name="e-client_code"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-specific_by_brand"
-----------------------------157103252818570
Content-Disposition: form-data; name="trans_store_out_0"
-----------------------------157103252818570
Content-Disposition: form-data; name="trans_store_out_1"
-----------------------------157103252818570
Content-Disposition: form-data; name="trans_date_beg_plan"
-----------------------------157103252818570
Content-Disposition: form-data; name="specific"
-----------------------------157103252818570
Content-Disposition: form-data; name="specific_type"
-----------------------------157103252818570
Content-Disposition: form-data; name="e-save"
Сохранить
-----------------------------157103252818570--

I just can't collect it for sending - I get an error 500.
The site is based on Django.
The actual algorithm is something like this:
  1. Login to the site
  2. Go to the page where the form is being submitted
  3. Submitting a form

All the data in the headers is correct, everything is OK, except for the last step - to correctly compose this very form :\
I have been racking my brain for 2 days :)
Lines like "----------------- ------------157103252818570" is the boundary

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-10-13
@dimonchik2013

you take requests (there are plenty of examples ) or pycurl (cooler and faster, but you can’t always install it) and do

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question