• WebBrows仿造Cookie


    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, OleCtrls, SHDocVw, mshtml, ExtCtrls, ComCtrls,
    WinSkinData;

    type
    TForm1 = class(TForm)
    SkinData1: TSkinData;
    Edit1: TEdit;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    CheckBox1: TCheckBox;
    Panel1: TPanel;
    StatusBar1: TStatusBar;
    WebBrowser1: TWebBrowser;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure WebBrowser1DownloadComplete(Sender: TObject);
    procedure WebBrowser1StatusTextChange(Sender: TObject;
    const Text: WideString);
    procedure WebBrowser1TitleChange(Sender: TObject;
    const Text: WideString);
    procedure WebBrowser1BeforeNavigate2(Sender: TObject;
    const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
    Headers: OleVariant; var Cancel: WordBool);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure CheckBox1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    var
    s:IHTMLdocument2;
    begin
    if checkbox1.Checked then
    begin
    s:=webbrowser1.document as IHTMLdocument2;
    s.cookie :=memo1.Text ; //αÔìCookie
    webbrowser1.Navigate(edit1.Text);
    end
    else
    webbrowser1.Navigate(edit1.Text);
    end;

    procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
    var
    s:IHTMLdocument2;
    begin
    if not checkbox1.Checked then
    begin
    s:=webbrowser1.document as IHTMLdocument2;
    memo1.Text :=s.cookie ; //È¡µÃCookie
    checkbox1.Enabled :=true;
    end;
    end;

    procedure TForm1.WebBrowser1StatusTextChange(Sender: TObject;
    const Text: WideString);
    begin
    statusbar1.Panels[1].Text :=text; //״̬ÌõÄÚÈÝ
    end;

    procedure TForm1.WebBrowser1TitleChange(Sender: TObject;
    const Text: WideString);
    begin
    form1.Caption :=text+' ¡ª KendyBrowser'; //±êÌâ
    end;

    procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
    const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
    Headers: OleVariant; var Cancel: WordBool);
    begin
    edit1.Text :=url; //µØÖ·À¸
    end;

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    var
    s:IHTMLdocument2;
    begin
    if key=#13 then
    begin
    if checkbox1.Checked then
    begin
    s:=webbrowser1.document as IHTMLdocument2;
    s.cookie :=memo1.Text ;
    webbrowser1.Navigate(edit1.Text);
    end
    else
    webbrowser1.Navigate(edit1.Text);
    end;
    end;

    procedure TForm1.CheckBox1Click(Sender: TObject);
    begin
    if memo1.ReadOnly then
    memo1.ReadOnly :=false
    else
    memo1.ReadOnly :=true;
    end;

    end.
  • 相关阅读:
    C#编程总结 字符转码
    获取 苹果UDID 序列号
    SVN :This XML file does not appear to have any style information associated with it.
    oracle 实时查询最耗CPU资源的SQL语句
    Oracle 优化和性能调整
    weblogic管理脚本
    weblogic状态监控脚本
    oracle性能检测sql语句
    Oracle动态性能表-V$SESSION_WAIT,V$SESSION_EVENT
    linux HBA 卡驱动安装
  • 原文地址:https://www.cnblogs.com/huqingyu/p/1114317.html
Copyright © 2020-2023  润新知