Próbowałem z Synapse, znalazłem parę przydatnych rzeczy na forum ale się nie udało bo nie mogłem się nawet zalogować :/
Chodzi o logowanie na pocztę GMail (przy WB oczywiście nie miałem z tym problemu...
function HTTPEncode(const AStr: string): string;
const
NoConversion = ['A'..'Z', 'a'..'z', '*', '@', '.', '_', '-'];
var
Sp, Rp: PChar;
begin
SetLength(Result, Length(AStr) * 3);
Sp := PChar(AStr);
Rp := PChar(Result);
while Sp^ <> #0 do
begin
if Sp^ in NoConversion then
Rp^ := Sp^
else if Sp^ = ' ' then
Rp^ := '+'
else
begin
FormatBuf(Rp^, 3, '%%%.2x', 6, [Ord(Sp^)]);
Inc(Rp, 2);
end;
Inc(Rp);
Inc(Sp);
end;
SetLength(Result, Rp - PChar(Result));
end;
function Explode(var a: TStrArray; Border, S: string): Integer;
var
S2: string;
begin
Result := 0;
S2 := S + Border;
repeat
SetLength(A, Length(A) + 1);
a[Result] := Copy(S2, 0,Pos(Border, S2) - 1);
Delete(S2, 1,Length(a[Result] + Border));
Inc(Result);
until S2 = '';
end;
procedure TForm1.Button1Click(Sender: TObject);
Var
C : String;
GALX, S : String;
HttpSend : THttpSend;
tempStr : string;
A : TStrArray;
I : Integer;
Begin
HttpSend := THttpSend.Create;
with HttpSend do
begin
KeepAlive := True;
Protocol := '1.1';
MimeType := Default_MimeType;
UserAgent := Opera_UserAgent;
//Pobieranie źródła strony z zlogowaniem
HttpSend.HTTPMethod('GET', 'https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&ss=1&scc=1<mpl=default<mplcache=2&hl=pl');
source1.Lines.LoadFromStream(HttpSend.Document);
for I := 0 to source1.Lines.Count - 1 do
begin
S := source1.Lines[I];
if Copy(S, 1, Length(' name="GALX"')) = ' name="GALX"' then
begin
Explode(A, 'value', source1.Lines[I +1]);
Explode(A, '="', A[1]);
Explode(A, '" />', A[1]);
GALX := A[0];
end;
end;
C := 'ltmpl=default<mplcache=2&continue=' + HTTPEncode('https://mail.google.com/mail/h/?zy=e&f=1') + '&service=mail&rm=false<mpl=default&hl=pl<mpl=default&scc=1&GALX=' + GALX + '&Email=LOGIN&Passwd=PASSWD&PersistentCookie=&rmShown=1&' + HTTPEncode('Zaloguj się');
HttpSend.Document.Write(Pointer(C)^, Length(C));
HttpSend.HTTPMethod('POST', 'https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1eic6yu9oa4y3&ss=1&scc=1<mpl=default<mplcache=2&hl=pl');
HttpSend.Clear;
HttpSend.HTTPMethod('POST', 'https://mail.google.com/mail/h/?zy=e&f=1');
source1.Lines.LoadFromStream(Httpsend.Document);
source1.Lines.SaveToFile('D:\test.html');
end;
end;
W źródle strony wywalało mi błąd 411 :/