INDY HTTP lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- pcurtis · 2020-11-19 10:57 Hi All, How would I implement this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     HTTPSend := THTTPSend.Create;    try      HTTPSend.Useragent := 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)';      HTTPSend.MimeType  := 'application/x-www-form-urlencoded';       WriteStrToStream(HTTPSend.Document,            ansistring('vb_login_username=someuser' +                       '&vb_login_password=' +                       '&s=' +                     '&securitytoken=guest' +                       '&do=login' +                     '&vb_login_md5password=asdfghjkjhgfdsdfghjkjhgfdsdfgbn' +                     '&vb_login_md5password_utf=asdfghjkjhgfdsdfghjkjhgfdsdfgbn'));;     Ok := HTTPSend.HTTPMethod('POST', 'http://somesite.com/login.php?do=login');       TextFromDocument := ReadStrFromStream(HTTPSend.Document, HTTPSend.Document.Size);       Memo1.Lines.Add('---------------');      Memo1.Lines.Add('Result = ' + HTTPSend.ResultCode.ToString + ' ' + HTTPSend.ResultString);      Memo1.Lines.Add('---------------');      Memo1.Lines.Add(HTTPSend.Headers.Text);      Memo1.Lines.Add('---------------');     // Memo1.Lines.Add(TextFromDocument);      Memo1.Lines.Add('---------------');      Memo1.Lines.Add(HTTPSend.Cookies[0]);      Memo1.Lines.Add(HTTPSend.Cookies[1]);      Memo1.Lines.Add(HTTPSend.Cookies[2]);      Memo1.Lines.Add(HTTPSend.Cookies[3]);      MyC := HTTPSend.Cookies.Text;      HTTPSend.Free; using INDY? Thanks in advance. ---------------------------------------------------------------------- Remy Lebeau · 2020-11-19 17:34 Like this: Code: [Select]HTTP := TIdHTTP.Create; try   HTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)';   Params := TStringList.Create;   try     Params.Add('vb_login_username=someuser');     Params.Add('vb_login_password=');     Params.Add('s=');     Params.Add('securitytoken=guest');     Params.Add('do=login');     Params.Add('vb_login_md5password=asdfghjkjhgfdsdfghjkjhgfdsdfgbn');     Params.Add('vb_login_md5password_utf=asdfghjkjhgfdsdfghjkjhgfdsdfg bn');         TextFromDocument := HTTP.Post('http://somesite.com/login.php?do=login', Params);   finally     Params.Free;   end;       Memo1.Lines.Add('---------------');   Memo1.Lines.Add('Result = ' + HTTP.ResponseCode.ToString + ' ' + HTTP.ResponseText);   Memo1.Lines.Add('---------------');   Memo1.Lines.AddStrings(HTTP.Response.RawHeaders);   Memo1.Lines.Add('---------------');   // Memo1.Lines.Add(TextFromDocument);   Memo1.Lines.Add('---------------');   // either:   with HTTP.CookieManager.CookieCollection do   begin     Memo1.Lines.Add(Cookies[0].CookieText);     Memo1.Lines.Add(Cookies[1].CookieText);     Memo1.Lines.Add(Cookies[2].CookieText);     Memo1.Lines.Add(Cookies[3].CookieText);   end;   // or:   with HTTP.CookieManager.CookieCollection.LockCookieList(caRead) do   try     Memo1.Lines.Add(Cookies[0].CookieText);     Memo1.Lines.Add(Cookies[1].CookieText);     Memo1.Lines.Add(Cookies[2].CookieText);     Memo1.Lines.Add(Cookies[3].CookieText);   finally     HTTP.CookieManager.CookieCollection.UnlockCookieList(caRead);   end;   // there is no direct equivalent to this statement in Indy:   //   //MyC := HTTP.Cookies.Text;   //   // but, you can produce such a string manually, by iteration through the   // CookieManager reading the individual TIdCookie.ClientCookie property   // values, eg:   // either:   MyC := '';   with HTTP.CookieManager.CookieCollection do   begin     for I := 0 to Count-1 do       MyC := Cookies[I].ClientCookie + sLineBreak;   end;   // or:   MyC := '';   with HTTP.CookieManager.CookieCollection.LockCookieList(caRead) do   try     for I := 0 to Count-1 do       MyC := Cookies[I].ClientCookie + sLineBreak;   finally     HTTP.CookieManager.CookieCollection.UnlockCookieList(caRead);   end; finally   HTTP.Free; ---------------------------------------------------------------------- pcurtis · 2020-11-19 18:23 Thanks. I'll take a look tomorrow.