GabryJ84 0 Posted July 25, 2022 Good evening to all! I am asking for help since I have a problem that is driving me nuts. I am trying to develop an automatic downloader that should get pdfs from a website where multiple pdfs are randomly published. To be honest, a program already existed, but they switched plaform and it has become a nightmare. The new platform is using PRIMEFACES to present different documents and give option to view or download pdfs. I have tried many combinations of POST data, but none satisfies application requirements and all I get is always Error 500. Maybe the problem is that I don't know how PRIMEFACES works, so I don't understand what to pass. The website is this: https://normativaesercizio.rfi.it/NormativaEsercizio/index.xhtml It is from the Italian railways and what you are supposed to do is to click on the name of a town (from both sides, different document type but same principle) and then click on the pdf icon to view or on the download icon to save. I have used Chrome to inspect what the POST data should contain and what the form is going to submit (in the section below), but it seems it is not enough. On the Delphi side, I used an IdHTTP.Post. Is someone more expert than me able to help? Thanks in advance. j_id_f:j_id_g_rppDD: 100 j_id_f:j_id_g_rppDD: 100 j_id_f_SUBMIT: 1 javax.faces.ViewState: UtaCXwQ+tZCf1lw8whSqB65gPMgz6uTJoJteeVorUHYM4IWFfLgwA+3/L/Cx9LwrM0K1QIfnvTZVdntVepxLGb74WnJCpWTB7LZ0TqjsT78mGkoL4u3BSKfmc6S9DZYxMrc8aNg4BpwOAWRp5NOeC5MRNT05mMC2ucYvPujY0EEkO0wJ2ZRo5vC5uqv2Y8DmBn2XgiAX+a6GyoM1mE2O42jSlQTZK1oKPm3GwkGoknRRh9XgFbIPiI2ekiPtgOcowxMd+n0uWEcfRW/eZAy1li+uOR+k2FF34jAB/V2k5Wh/Tuj1dawB1eT7uIcf56GB6onw28rElyHqcPj+YJVKR2CqXzX0SJs2X/l+equFng8NHK0PwN0dBB81fp9iBY6H+e0y6Enct/0OOteMaLXFJ8uGOb26ZwL8dL3X1adryEMoUCBx/hgeV/ntMuhJ3Lf9ikLGA6lmOXnvAyeg8UgFaUt5Icvih1N2LtMJ+b/+bQ20KbxT+GGHhW4iBoLKO3fSsrLyLveHVf+PJHyt3VyWrsTAlBOY4UszrDQQQF36Iogs6htMgsP6wn/lKhW6vavNU4E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Btfx2fsjp5mVOcXEAvrsPGeE5BtzgLc+O4Qq+NFXDkZtuwg7ZzX6fQA/5kEYr/CodJT/AbnFpZ5/PcWPSY8hCHCCQY1A6XoKMZC26M2lewbRPErY+fMjSgeAoRjq1l5VqnBaqfQWGjREiFkfITz1fUMqOlAqj4p0ZWjc5/GIvzNhe/76zes4Cm6mUHMYDsgN/e7ccsN3Zp30kWUSW/Oliv7eyg01yFmk62H6V/Vwp9Qc9KVHVp1uE6etWfycRxQkSUCqIE+nGuN4cVETdKD5bb6Ufb61PJFBuCKWeppx2YF524LtscLmYxxGAvTM4OREn/W/JXQO7Wf8xCMEnPRtsPEBcDQOCR8J/mo9fFLCpOGk6GyoM1mE2O4/Vj3qtTsUPkcUoW10bwNrmevdPzOR1BxRDCgfAGxDtnD3LZW5Zyy1JFSVZlyTYrUpr+Krjxdr+CXLE1GDz+P1OL39671u1tBPeoKlpPB2r98JasgckZ6RzmGZcp2MDSIqufk5X1wD7tW5IyoZMoZF4VoKmch1vyKPFZRfP8QZ1AdVAzfucAEa8eWEb/C6j9I8j5Db8hOoA4HtkhxxBXsgOaNmLno2Rpgjh52XODuc0ZUA7N/kaLra/9ws6e/KQ2nfFnF9pZqS4XaK84APVCMx5XLf+uZC0sT4Df4Pd6gCXzXP1hoauCdGjwcWEjL6wiSPKtXRo2i3AEd8h6nCsA0o7lSu1vKuUClCd4vXsSZbzJybvL73DUs3NcsTUYPP4/U4vf3rvW7W0E96gqWk8Hav12WSYFDq2oPLKXaFW3dZW2Pb64JicgBDYT4/LEetonRwns1cVOZycvcyrKKMTLCSm6ll1o4GakMBAf98zsG09g/9T7riNjLyz6fW+R8QSVYlhiqG+IcCZ6tXEu3yoAg3/C0m0QJsn51lembDJblaQnku5ZNtxKMCxUAjyN j_id_f:j_id_g:56:j_id_w: j_id_f:j_id_g:56:j_id_w Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate, br Accept-Language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6 Cache-Control: max-age=0 Connection: keep-alive Content-Length: 2938 Content-Type: application/x-www-form-urlencoded Cookie: oam.Flash.RENDERMAP.TOKEN=-uxrfp4qya; JSESSIONID=0000xNWX5pdEqyHq0NVTDKBaEMa:-1 Host: normativaesercizio.rfi.it Origin: https://normativaesercizio.rfi.it Referer: https://normativaesercizio.rfi.it/NormativaEsercizio/detail.xhtml?doctype=CT&compartimento=MI sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: same-origin Sec-Fetch-User: ?1 sec-gpc: 1 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Stream := TMemoryStream.Create; Params := TStringStream.Create; dwn.Request.Method := 'POST'; dwn.Request.ContentType := 'application/x-www-form-urlencoded'; dwn.Request.Referer := 'https://normativaesercizio.rfi.it/NormativaEsercizio/detail.xhtml?doctype=' + dnShort(TTabSheet(lv.Parent).Caption) + '&compartimento=' + dnShort(TTabSheet(TPageControl(TTabSheet(lv.Parent).Parent).Parent).Caption); Params.WriteString(HERE_POST_DATA); IdHTTP.Post(HTTPEncode('https://normativaesercizio.rfi.it/NormativaEsercizio/detail.xhtml'), Params, Stream); Stream.SaveToFile(path + item + '.pdf'); Stream.Clear; Share this post Link to post
Fr0sT.Brutal 900 Posted July 26, 2022 Get full dump of the request your app sends and ensure it's identical to what Chrome sends. Share this post Link to post