How to create a multipart/form-data request in Scrapy?

Trying to create a query in scrape on the basis of the page that sends a POST request, which will redirected and returns a link to the PDF.
Here is the data from Dev tools:
FormData
hostURL: http://oris.co.palm-beach.fl.us/or_web1/
pdfPath: \\wcp01zfs-03.clerk.local\files2\ORISPDF\
pdfURL: http://oris.co.palm-beach.fl.us/pdf/
pages: 1
id: 22591587
mpages: 1
doc_id: 22591587
page1: image_from_file.asp?imageurl=\\ors_fs\ORImage\O\30338\O. 30338.0268.0001.tif
WaterMarkText: 1

Headers:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,EN;q=0.8,uk;q=0.7
Cache-Control: max-age=0
Connection: keep-alive
Content-Length: 1095
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarysGRfL8zMeuSs4zsh
Cookie: ASPSESSIONIDACDTTCTA=OJBBKBLCGCBLFGODHMLKCIFG; BIGipServer~external~coc_oris.mypalmbeachclerk.com_80=rd102o00000000000000000000ffff978432b7o80; BIGipServer~external~coc_oris.mypalmbeachclerk.com_8080=rd102o00000000000000000000ffff978433b7o8080
DNT: 1
Host: oris.co.palm-beach.fl.us:8080
Origin: http://oris.co.palm-beach.fl.us
Referer: http://oris.co.palm-beach.fl.us/or_web1/details_img.asp?doc_id=22591587&pg_count=1&pg_num=1&click=1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36


If you try formdata in the form of a dict to pass, that on one line the last backslash exabit quote. it turns out without backslash not the link.
If you just copy Formdata in the form of in the form of source code, some characters are not displayed correctly.
5c9f33a5d457a909428533.png
In the end, the redirect goes to the link type
http://oris.co.palm-beach.fl.us:8080/PdfServlet/nv_433__img.pdf
and returns a 404.
while the working link looks like this -
http://oris.co.palm-beach.fl.us/pdf/nv_643_22591587_img.pdf

Here is the form code that it is trying to imitate.
<td valign="bottom">

 <form name="courtform" action="http://oris.co.palm-beach.fl.us:8080/PdfServlet/PdfServlet27" method="post" enctype="multipart/form-data">

 <input type="hidden" name="hostURL" value="http://oris.co.palm-beach.fl.us/or_web1/" size="60">
 <input type="hidden" name="pdfPath" value="\\wcp01zfs-03.clerk.local\files2\ORISPDF\" size="60">
 <input type="hidden" name="pdfURL" value="http://oris.co.palm-beach.fl.us/pdf/" size="60">

 <input type="hidden" name="pages" value="1" size="60">
 <!--<input type="hidden" name="pages" value="1" size="60">-->
 <input type="hidden" name="id" value="22590889" size="60">
 <input type="hidden" name="mpages" value="1" size="60">
 <input type="hidden" name="doc_id" value="22590889" size="60">

 <input type="hidden" name="page1" value="image_from_file.asp?imageurl=\\ors_fs\ORImage\O\30336\O. 30336.1200.0001.tif" size="60">

 <input type="hidden" name="WaterMarkText" value="1" size="60">

 &nbsp;&nbsp;<input name="button" type="button" value="View PDF" onclick="javascript:ValidateAndSubmit(this.form)">&nbsp;&nbsp;

</form></td>

What am I doing wrong?
March 19th 20 at 09:16
0 answer

Find more questions by tags Scrapy