Einzelnen Beitrag anzeigen

t.roller
(Gast)

n/a Beiträge
 
#10

AW: Ebay Login geht nicht mehr

  Alt 22. Jun 2016, 20:51
Hier habe ich eine Lösung: (EXE im Anhang)
Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure WebBrowser1DocumentComplete(ASender: TObject;
      const pDisp: IDispatch; const URL: OleVariant);
    procedure FormFill(WebBrowser1:TWebBrowser; ElementName, Value: string);
    procedure FormSubmit(WebBrowser1:TWebBrowser; ElementName, Value: string);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  flag:Boolean=False;

implementation

{$R *.dfm}

procedure TForm1.FormFill(WebBrowser1:TWebBrowser; ElementName, Value: string);
var
  i, j: Integer;
  FormItem: Variant;
begin
  for I := 0 to WebBrowser1.OleObject.Document.forms.Length - 1 do
  begin
    FormItem := WebBrowser1.OleObject.Document.forms.Item(I);
    for j := 0 to FormItem.Length - 1 do
    begin
      try
        if FormItem.Item(j).Name = ElementName then
        begin
          FormItem.Item(j).Value := Value;
          Exit;
        end;
      except
        Exit;
      end;
    end;
  end;
end;

procedure TForm1.FormSubmit(WebBrowser1:TWebBrowser; ElementName, Value: string);
var
  i, j: Integer;
  FormItem: Variant;
begin
   for I := 0 to WebBrowser1.OleObject.Document.forms.Length - 1 do
  begin
    FormItem := WebBrowser1.OleObject.Document.forms.Item(I);
    for j := 0 to FormItem.Length - 1 do
    begin
      try //when the Submit Button is found click
        if FormItem.Item(j).type = ElementName then
        begin
          FormItem.Item(j).Value := Value;
          FormItem.Item(j).click;
        end;
      except
        Exit;
      end;
    end;
  end;
end;

procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject;
  const pDisp: IDispatch; const URL: OleVariant);
begin
  if flag then exit;
  FormFill(WebBrowser1, 'userid', Edit1.Text);
  FormFill(WebBrowser1, 'pass', Edit2.Text);
  FormSubmit(WebBrowser1, 'submit','sgnBt');
  flag := true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('https://signin.ebay.de/ws/eBayISAPI.dll?SignIn');
end;

end.
Angehängte Dateien
Dateityp: zip EbayLogin.zip (892,3 KB, 10x aufgerufen)
  Mit Zitat antworten Zitat