Automatyczne zalogowanie się...

0

Witam znalazłem parę kodów...

tylko u mnie sprawa wygląda następująco nie mam pojęcie jak mu kazać wpisać login w odpowiednie pole

struktóra logowania na stronie

onsubmit="document.getElementById('form_login').disabled=true;">
<td nowrap class="tabelka_br">Login:</td>

<td align="right">
<input type="text" name="login" id="f_login" size="10" maxlength="21" style="width:150px;" value=""><br>
</td>
</tr>
<tr>
<td nowrap class="tabelka_br">Hasło:</td>
<td align="right">
<input type="password" name="pass" id="f_pass" size="10" maxlength="30" style="width:150px;"><br>
</td>

Czy mnie interesują kratki: login i pass ?

teraz kod w delphi

function FillForm(WebBrowser: TWebBrowser; FieldName: string; Value: string): Boolean; 
var 
  i, j: Integer; 
  FormItem: Variant; 
begin 
  Result := False; 
  //no form on document 
  if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then 
  begin 
    Exit; 
  end; 
  //count forms on document 
  for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do 
  begin 
    FormItem := WebBrowser.OleObject.Document.forms.Item(I); 
    for j := 0 to FormItem.Length - 1 do 
    begin 
      try 
        //when the fieldname is found, try to fill out 
        if FormItem.Item(j).Name = FieldName then 
        begin 
          FormItem.Item(j).Value := Value; 
          Result := True; 
        end; 
      except 
        Exit; 
      end; 
    end; 
  end; 
end; 


//When the document is complete try to fill out the field homepage with the url 
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; 
  const pDisp: IDispatch; var URL: OleVariant); 
begin 
  if FillForm(WebBrowser1, 'homepage', 'http://www.swissdelphicenter.ch') = False then 
    ShowMessage('Error. Field not available or no Form found.');
end;

// Show the Webbrowser-Progress in Label1 
procedure TForm1.WebBrowser1ProgressChange(Sender: TObject; Progress, ProgressMax: Integer); 
begin 
  if ProgressMax = 0 then 
  begin 
    label1.Caption := ''; 
    Exit; 
  end; 
  try 
    if (Progress <> -1) and (Progress <= ProgressMax) then 
      label1.Caption := IntToStr((Progress * 100) div ProgressMax) + '% loaded...' 
    else 
      label1.Caption := ''; 
  except 
    on EDivByZero do Exit; 
  end; 
end; 


//For example you can load the page /en/addtip.php to the TWebBrowser 
//When the document is Complete the form where you can put your homepage 
//address is filled out 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  Webbrowser1.Navigate('http://www.swissdelphicenter.ch/en/addtip.php'); 
  // Show the Titel of the currently active Webpage in the titlebar 
  // Den Titel der aktuellen Webseite in der Titeleiste anzeigen 
  Caption := Webbrowser1.OleObject.Document.Title; 
end;

jak przerobić kod by wpisywał w odpowiednie pola login i gaslo?

0
WiecznyStudent napisał(a)

Czy mnie interesują kratki: login i pass ?

Oczywiście, że tak ... :P

WiecznyStudent napisał(a)

jak przerobić kod by wpisywał w odpowiednie pola login i gaslo?

Nie chce mi się sprawdzać tego kodu w praktyce, więc nie jestem pewny prawidłowości kodu, ale powinieneś zrobić coś w stylu:

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; 
  const pDisp: IDispatch; var URL: OleVariant); 
begin 
  if FillForm(WebBrowser1, 'login', 'TwojLogin') = False then 
    ShowMessage('Error. Field not available or no Form found.');
  if FillForm(WebBrowser1, 'pass', 'TwojeHasło') = False then 
    ShowMessage('Error. Field not available or no Form found.');
end;

(najlepiej te 2 instrukcje wsadź w jeden warunek, mi juz nie chcialo sie pisac :P )
Ten kod wstawiasz zamiast tego fragmentu:

//When the document is complete try to fill out the field homepage with the url 
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; 
  const pDisp: IDispatch; var URL: OleVariant); 
begin 
  if FillForm(WebBrowser1, 'homepage', 'http://www.swissdelphicenter.ch') = False then 
    ShowMessage('Error. Field not available or no Form found.');
end;
0

dziękuje bardzo za pomoc!

A jeszcze jedno pytanie wpisuje sam login i hasło ale jak wdusić mu enter jak kazać mu sie zalogować gdy zaloguj to button

0

w ie nie da rady tego zrobic jednie w firefox mam linka z bot buta ale gdy w ie wpisze haslo i wklejam link logowania wyskakuje nieprawidlowe haslo ;/

ale juz mam pomysl jakby to obejsc

Left side cannot be assigned to

begin
  if FillForm(WebBrowser, 'login', 'mojlogin') = False then;
  Memo1.Lines.add('Konto zarejestrowane dla urzytkownika moj login! BRAK DOSTEPU!');

<b>   form1.Close:=true;</b>
  if FillForm(WebBrowser, 'pass', 'haslo') = false then;
     ShowMessage('Bledne haslo!');

   timer5.enabled:=false
0

chodź nie to odpada

hmm myśle jakby zrobić że gdy ktoś wpisze inny login niż tzreba to wyłancza się aplikacja ;)

0

begin
if FillForm(WebBrowser, 'login', 'mojlogin') = False then;

form1.Close:=true;
if FillForm(WebBrowser, 'pass', 'haslo') = false then;

end;

WebBrowser.Navigate('http://www.blabla.com/login.php?form_login=1');

timer5.enabled:=false

end;


no i sie nie loguje pisze że błędne haslo ;/ POMOCY!
0
begin
FillForm(WebBrowser, 'login', 'login');
FillForm(WebBrowser, 'pass', 'haslol');
WebBrowser.Navigate('http://www.blabla.com/login.php?form_login=1');
   timer5.enabled:=false;



end;

hmm dlaczego sie nie loguje w ff działa

1 użytkowników online, w tym zalogowanych: 0, gości: 1