全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1745
推到 Plurk!
推到 Facebook!

DELPHI有辦法寫"檢查網頁有更新後,並立即通知的功能嗎

尚未結案
seedbcc
高階會員


發表:232
回覆:272
積分:105
註冊:2003-12-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-25 18:01:46 IP:221.169.xxx.xxx 未訂閱
讓IE或其它網頁瀏覽器 所開啟的網頁(任一網頁) 做定期更新 , 若檢查內容有不同時,做即時通知 可否請各思考一下 這個功能有辦法撰寫嗎 需要什麼元件
supman
尊榮會員


發表:29
回覆:770
積分:924
註冊:2002-04-22

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-04-25 18:20:26 IP:61.70.xxx.xxx 未訂閱
您好: 小弟沒做過這樣東西,不過這個應該能辦到吧. 您的連結主頁去把每一個連結的檔案抓下來,存起來,當下一次,如:一天後再抓一次,進行比對,檔案如果不一樣大,或者內容也被變更了,就發E-Mail通知您. 抓網頁的方式可以參考下面: http://delphi.ktop.com.tw/topic.php?topic_id=31852 http://delphi.ktop.com.tw/topic.php?topic_id=56611 發表人 - supman 於 2005/04/25 18:24:29
pcboy
版主


發表:177
回覆:1838
積分:1463
註冊:2004-01-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-04-26 08:20:40 IP:210.69.xxx.xxx 未訂閱
小弟有寫過這樣程式, 方法就如 supman 所說 然後用 排程 設定每天幾點執行 有變化就 彈出畫面 or 寄出信件
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案!

子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問!
seedbcc
高階會員


發表:232
回覆:272
積分:105
註冊:2003-12-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-04-26 09:00:08 IP:221.169.xxx.xxx 未訂閱
連結到主頁 可能不適合 因為我的檢查的網頁,就類似 delphi ktop 討論區裡的一篇文章 例如本篇 檢查有更新後才傳給我 我可能是 五分鐘檢查一次
supman
尊榮會員


發表:29
回覆:770
積分:924
註冊:2002-04-22

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-04-26 09:55:54 IP:61.70.xxx.xxx 未訂閱
您好: 不一定是連結到主頁,內頁的也是一個網址阿, 比如檢查主頁 http://delphi.ktop.com.tw/active_nowin.asp 檢查內頁 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=69770 如果您要給一個主頁就去檢查出哪些連結有更新,像Telport那樣砍站軟體,也一樣可以辦到,但遇到JAVA寫的連結,就砍不到了.
seedbcc
高階會員


發表:232
回覆:272
積分:105
註冊:2003-12-10

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-04-27 08:58:04 IP:221.169.xxx.xxx 未訂閱
請教pcboy2兄 有沒有 小小的範例 可以供我參考呢
pcboy
版主


發表:177
回覆:1838
積分:1463
註冊:2004-01-13

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-04-28 11:41:19 IP:210.69.xxx.xxx 未訂閱
Delphi 7 Enterprise 寫的, 確認是可以正常執行的    
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP, ComCtrls,  Shellapi, IdTCPServer, IdSMTPServer,
  IdMessageClient, IdSMTP, IdMessage;    type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Memo3: TMemo;
    Label1: TLabel;
    Memo4: TMemo;
    Label2: TLabel;
    Button1: TButton;
    IdHTTP1: TIdHTTP;
    RichEdit1: TRichEdit;
    Button2: TButton;
    IdSMTP1: TIdSMTP;
    IdMessage1: TIdMessage;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1: TForm1;      DateString, TimeString : String;
  YearStr, MonthStr, DayStr, HourStr, MinStr, SecStr : String;
  AMPM : String;
  CurDateTime : String;
  BackupFileName : String;
  ChangeFileName : String;
  CompareFileName : String;    implementation    {$R *.dfm}    procedure FileNameMake;
begin
  // ***************** 計算目前的年月日時分秒當檔案名稱使用 ******************
  DateString := DateToStr(date);
  TimeString := TimeToStr(Time);      YearStr := DateString[1]  DateString[2]   DateString[3]   DateString[4] ;
  if (DateString[7]='/') then   // 月份為1個數字, 1-9 月
  begin
    MonthStr := '0'   DateString[6];    //月份補成 2 位
    if (DateString[9]='') then  // 日期為 1 個數字
      DayStr := '0' DateString[8]
    else
      DayStr := DateString[8]  DateString[9];
  end
  else      // 月份為2個數字, 10-12 月
  begin
    MonthStr := DateString[6]  DateString[7];
    if (DateString[10]='') then
      DayStr := '0' DateString[9]
    else
      DayStr := DateString[9]  DateString[10];
  end;      AMPM:=TimeString[1] TimeString[2] TimeString[3] TimeString[4];
  HourStr := TimeString[6] TimeString[7];
  if (AMPM='上午') and (HourStr='12') then  HourStr := '00';
  if (AMPM='下午') and (HourStr<>'12') then  HourStr := IntToStr(StrToInt(HourStr) 12);      MinStr := TimeString[9] TimeString[10];
  SecStr := TimeString[12] TimeString[13];
  CurDateTime := YearStr   MonthStr   DayStr   '-'   HourStr   MinStr   SecStr;      //********************************************************************      // 設定儲存 Log 檔名
  BackupFileName := 'Log\Symantec'   CurDateTime   '.htm';
  ChangeFileName := 'Log\Symantec'   CurDateTime   'Var.htm';
  CompareFileName := 'Log\Symantec.htm';
end;    procedure TForm1.Button1Click(Sender: TObject);
var
  i, j : integer;
  s : String;
  VirusDataStart : integer;
  VirusDataEnd : integer;
  Same : integer;
//  Attachment: TIdAttachment;  // 自己要加上, 郵寄附件
  EmailCount : integer;
begin      RichEdit1.PlainText:=True;  // 設定 RichEdit1 讀取的資料當純文字      // 初始化值
  Button1.Enabled := False ;
  Button1.Caption := '執行中';
  RichEdit1.Lines.Clear;
  Memo1.Lines.Clear;
  Memo2.Lines.Clear;
  Memo3.Lines.Clear;
  Memo4.Lines.Clear;
  FileNameMake;   // 記算日期時間當檔案名稱;      if FileExists('email.txt') then
    Memo3.Lines.LoadFromFile('email.txt');      {  // Memo1 讀取的網頁不回自動換行 , 改用 RichEdit1
  Memo1.Lines.Clear;
  IdHTTP1.HandleRedirects:=true;
  Memo1.Text:=IdHTTP1.Get('http://www.symantec.com.tw/');
  }      // 讀取網頁
  IdHTTP1.HandleRedirects:=true;
  RichEdit1.Text:=IdHTTP1.Get('http://www.symantec.com.tw/');
  Memo4.Lines.Add('讀取Symantec網頁內容');      // 找尋病毒資訊開始行
  VirusDataStart:=0;
  VirusDataEnd:=0;
  i:=0;
  while (i < RichEdit1.Lines.Count) and (VirusDataStart=0) do
  begin
    s:='';
    if (StrLen(PChar(RichEdit1.Lines[i]))>=12) then
    begin
      for j:=1 to 12 do
        s:= s   RichEdit1.Lines[i][j];
      if (s='最新安全威脅') then
      begin
        VirusDataStart := i;
        Memo4.Lines.Add('資料開始行 : '   IntToStr(VirusDataStart));
      end;
    end;
    i:=i 1;
  end;      // 找尋病毒資訊結束行
  while (i < RichEdit1.Lines.Count) and (VirusDataEnd=0) do
  begin
    s:='';
    if (StrLen(PChar(RichEdit1.Lines[i]))>=8) then
    begin
      for j:=1 to 8 do
        s:= s   RichEdit1.Lines[i][j];
      if (s='
') then begin VirusDataEnd := i; Memo4.Lines.Add('資料結束行 : ' IntToStr(VirusDataEnd)); end; end; i:=i 1; end; // 找到的病毒資訊放 Memor1 中 for i:= VirusDataStart to VirusDataEnd do Memo1.Lines.Add(RichEdit1.Lines[i]); // Memo1 的資料寫入後會多了換行 (原因不明), 所以必須重新讀取 Memo1.Lines.SaveToFile(BackupFileName); Memo1.Lines.LoadFromFile(BackupFileName); Same:=0; // 讀取上次的病毒紀錄到 Memo2 if FileExists('Log\Symantec.htm') then begin Memo2.Lines.LoadFromFile('Log\Symantec.htm'); Memo4.Lines.Add('讀取備份病毒資訊'); end else begin // 第一次執行, 記錄不存在, 產生一個新的 Memo1.Lines.SaveToFile('Log\Symantec.htm'); Memo4.Lines.Add('第一次執行, Log\Symantec.htm 記錄不存在, 產生一個新的'); Same:=1; end; if (Same=0) then if (Memo1.Text= Memo2.Text) then begin Memo4.Lines.Add('內容相同'); Same:=1; end else begin Memo4.Lines.Add('內容不同'); ShellExecute(handle, 'open', 'http://www.symantec.com.tw/', '', '', SW_SHOWNORMAL); Same:=0; Memo1.Lines.SaveToFile('Log\Symantec.htm'); end; // 如果網頁有變化, 寄出通知信件 if Same = 0 then begin // 寄出掃描結果 IdSMTP1.Host := '127.0.0.1'; // 請在本機架設 Mail Server, http://www.argosoft.com/ 有免費的 IdSMTP1.Username := 'webmaster'; // 請在 mail Server 上建立此帳號 IdMessage1.From.Name := '重大病毒自動通報系統'; IdMessage1.From.Address := 'webmaster@127.0.0.1'; // 處理收件者名單 s:=''; IdMessage1.Recipients.Clear; if FileExists('email.txt') then begin Memo3.Lines.LoadFromFile('email.txt'); // Memo4.Lines.Clear; Memo4.Lines.Add('讀取email.txt'); end else MessageDlg ('收件者名單 email.txt 不存在!', mtError, [mbOk], 0); EmailCount :=Memo3.Lines.Count; for j := 0 to EmailCount-1 do begin if StrLen(PChar(string(Memo3.Lines[j]))) > 3 then // 確認不是空行 with IdMessage1.Recipients.Add do begin Name := Memo3.Lines[j]; Address := Memo3.Lines[j]; end; end; s:=IdMessage1.Recipients.EmailAddresses; Memo4.Lines.Add('寄通知信給 : ' s); IdMessage1.Subject := '重大病毒自動通報系統 ' DateToStr(Date) ' ' TimeToStr(Time); IdMessage1.Body.Clear; IdMessage1.Encoding:= meMIME; IdMessage1.ContentType:= 'text/html'; IdMessage1.Body.Add('賽門鐵克 (Symantec) '); IdMessage1.Body.AddStrings(Memo1.Lines); //IdMessage1.Body := Memo1.Lines; try if not IdSMTP1.Connected then IdSMTP1.Connect; IdSMTP1.Send(IdMessage1); IdSMTP1.Disconnect; except MessageDlg('寄信失敗 (請架設 Local Mail Server 和帳號 webmaster)', mtWarning, [mbOK], 0) end; // 附件必須清除, 不然會一直累加 // Attachment.Destroy; end; // if Same = 0 then 寄信 Memo4.Lines.Add('<<執行結束>>'); Button1.Caption := '執行結束'; Button2.Enabled := True ; end; procedure TForm1.FormCreate(Sender: TObject); begin Button1.Click; // 自動開始執行 Application.Terminate; // 執行完畢自動結束 end; procedure TForm1.Button2Click(Sender: TObject); begin Application.Terminate; end; end. ********************* 如果您滿意答案,請結案 *********************
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案!

子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問!
seedbcc
高階會員


發表:232
回覆:272
積分:105
註冊:2003-12-10

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-04-29 11:52:15 IP:221.169.xxx.xxx 未訂閱
procedure FileNameMake; 請教 這是在哪宣告的 ?????
pcboy
版主


發表:177
回覆:1838
積分:1463
註冊:2004-01-13

發送簡訊給我
#9 引用回覆 回覆 發表時間:2005-05-02 10:58:48 IP:210.69.xxx.xxx 未訂閱
不需要, 這樣就可以執行啦 剛剛試驗一下, 很正常 ********************* 如果您滿意答案,請結案 *********************
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案!

子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問!
Ktop_Robot
站務副站長


發表:0
回覆:3511
積分:0
註冊:2007-04-17

發送簡訊給我
#10 引用回覆 回覆 發表時間:2007-04-26 13:50:51 IP:000.000.xxx.xxx 未訂閱
提問者您好:


以上回應是否已得到滿意的答覆?


若已得到滿意的答覆,請在一週內結案,否則請在一週內回覆還有什麼未盡事宜,不然,
將由版主(尚無版主之區域將由副站長或站長)自由心證,選擇較合適之解答予以結案處理,
被選上之答題者同樣會有加分獎勵同時發問者將受到扣 1 分的處分。不便之處,請見諒。


有問有答有結案,才能有良性的互動,良好的討論環境需要大家共同維護,感謝您的配合。

------
我是機器人,我不接受簡訊.
系統時間:2024-05-12 9:45:07
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!