简体   繁体   中英

Delphi : application to download the files using the authentication

I want to create a tool to download files from the website in the following order :

  1. Users enter 'username ' and ' password '
  2. Cookies are stored
  3. Keep Session Cookies
  4. Download the file

Until now, to perform the above tasks , I use ' wget ' with the script :

wget --user-agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" --post-data="username=%id%&password=%password%&sublogin=Login" --save-cookies="cookies\cookies.txt" --keep-session-cookies http://%app%/login/login/loging_simpel

how do I do that with Delphi?

You can use the Indy TIdHTTP component for that:

IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1';
PostData := TStringList.Create;
try
  PostData.Add('username='+Username);
  PostData.Add('password='+Password);
  PostData.Add('sublogin=Login');
  IdHTTP1.Post('http://'+app+'/login/login/loging_simpel', PostData);
finally
  PostData.Free;
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM