Solved

Getting the next HTML page

Posted on 2001-08-09
11
165 Views
Last Modified: 2010-04-06
Hi All,

I have D4 and win2k with NT. I am using a ActiveX WebBrowser_V1.
I am saving each html page and an associated text. This program always works on
any first selection correctly. But on the next selection on the same 'run'  it does not 'clear' itself so
that the next set of views are saved with the correct information. In fact it may be data
from  the previous one.


 procedure TForm1.Button1Click(Sender: TObject);
var
  Doc, V, Bod: OleVariant;
begin
  Memo1.Clear;
  Doc := '';
  Infolabel.Caption := '';
  Infolabel.Caption := 'Loading';
  webBrowser_V11.Navigate(Edit1.Text, V, V, V, V);
  while webBrowser_V11.Busy do
    Application.ProcessMessages;
  Doc := webBrowser_V11.Document;
  Bod := Doc.Body;

  Memo1.Text := Bod.InnerHTML;

  Memo1.Lines.SaveToFile(ExtractFilePath(Application.exeName) + Edit2.Text);

  Memo1.Text := Bod.InnerText;

  Memo1.Lines.SaveToFile(ExtractFilePath(Application.exeName) + Edit3.Text);

  Infolabel.Caption := 'Done';
end;


procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  if RadioGroup1.ItemIndex = 0 then begin Edit1.Text := 'http://users.swing.be/francois.piette/wsocketu.htm'; ;
    Edit2.Text := 'TWSocView.html'; Edit3.Text := 'TWSocView.txt'; end;

  if RadioGroup1.ItemIndex = 1 then begin Edit1.Text := 'http://www.marthastewart.com/television/program_guide/index.asp';
    Edit2.Text := 'MarthaAsp.html'; Edit3.Text := 'MarthaAsp.txt'; end;

  if RadioGroup1.ItemIndex = 2 then begin Edit1.Text := 'http://mathforum.com/mathgrepform.html';
    Edit2.Text := 'MathView.htm'; Edit3.Text := 'MathView.txt'; end;

  if RadioGroup1.ItemIndex = 3 then begin Edit1.Text := 'http://MarthaStewart.com';
    Edit2.Text := 'MarthaView.html'; Edit3.Text := 'MarthaComView.txt'; end;

  if RadioGroup1.ItemIndex = 4 then begin Edit1.Text := 'http://town.springhill.ns.ca/Anne_Murray_Centre.htm';
    Edit2.Text := 'AnnMury.html'; Edit3.Text := 'AnnMury.txt'; end;

  if RadioGroup1.ItemIndex = 5 then begin Edit1.Text := 'http://pacific.commerce.ubc.ca/xr/rates.html';
    Edit2.Text := 'PacMony.html'; Edit3.Text := 'PacMony.txt'; end;

end;

procedure TForm1.FormShow(Sender: TObject);
begin
  RadioGroup1.ItemIndex := 0;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Application.Terminate;
end;

end.

A correction is requested

Delphi3
0
Comment
Question by:delphi3
  • 6
  • 2
  • 2
  • +1
11 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 6371709
Try clear DOC,V, Bod variants.
DOC:=UNASSIGNED;
V:=UNASSIGNED;
Bod:=UNASSIGNED;
after Memo1.Clear or
VarClear(DOC);
VarClear(V);
VarClear(Bod);
after infoLabel.Caption:='done';
ziolko.
0
 
LVL 6

Expert Comment

by:edey
ID: 6372781
And a little tip - IE has several overloaded navigate methods so you don't always need to call webBrowser_V11.Navigate(Edit1.Text, V, V, V, V); . If you don't need to pass any sepecial headers (unlikely) you can call webBrowser_V11.Navigate(Edit1.Text);

Also, webBrowser_V1 is, I believe an encapsulation of IE 4 & webBrowser is IE 5, so if you don't _need_ IE 4 I'd suggest using TWebBrowser instead.

GL
Mike
0
 
LVL 4

Author Comment

by:delphi3
ID: 6373057
ziolko,

Sorry but neither of these fixes work in my program, before or afterward.
I even tried both, but still the same problem.

I will  try  Mike's  suggestion next.

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
ID: 6373233
Mike,

I know that this is like an adventure that has to be mountain climbing, but with no vision.
First, I tried removing the (V,V,V,V) and the message I got is

[Error] GetWebBrowserUnit1.pas(54): Not enough actual parameters
It wants all 4 V's in a row.

Next: A look on the palet shows only 1 icon available that of webBrowser_V1 and when it is placed
on the form then webBrowser_V1 is the one.

At some point in this game I did have 2 icons on the pallet that BOTH looked that same. Some how
one of them disappeared. So I did look in the Component pallet and under import ActiveX
Microsoft Internet Active controls (version 1.1) It Shows 2 Class names:
 TwebBrowser_V1
 TwebBrowser

then  with install button pushed it says that  TwebBrowser_V1  is already installed.

Mike, I cannot the  TwebBrowser to be on the pallet

Delphi3
0
 
LVL 6

Accepted Solution

by:
edey earned 50 total points
ID: 6373704
Hmmm, Does your system curently have IE 5+ installed (and working)? Can you reinstall the activeX wrappers if you uninstall TWebBrowser_V1 first?

GL
Mike
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:delphi3
ID: 6382413
Mike,
There is no practical purpose to continue with this. This ActiveX unit operation is poor,
in my estimation.

1. I have, if this is what you are asking for, Microsoft Windows 2000, 5.00.2195 Service pack 1
2. I choose not to trash it all to recover TWebBrowser. I have no assurance that it will work and
the amount of work necessary to get my D4 package back up with the special inserts.

3. So now I have parsed the operation of Click1, Now Click1 is to just get the web page and
Click2 is to get the rest of it. I think that this arrangement works OK for one as shown below.
But I am not happy with the results.



procedure TForm1.Button1Click(Sender: TObject);
var
  V : OleVariant;
begin
webBrowser_V11.Navigate(Edit1.Text, V, V, V, V);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  Doc,  Bod: OleVariant;
begin
   while webBrowser_V11.Busy do
     Application.ProcessMessages;
  Doc := webBrowser_V11.Document;
  Bod := Doc.Body;

  Memo1.Text := Bod.InnerHTML;
  Memo1.Lines.SaveToFile(ExtractFilePath(Application.exeName) + Edit2.Text);

  Memo1.Clear;

  Memo1.Text := Bod.InnerText;
  Memo1.Lines.SaveToFile(ExtractFilePath(Application.exeName) + Edit3.Text);
end;

 I don't know who really should get the points for the help. But anyway I will give them to
 Mike and a 'B'  grade for the effort.

Thanks All for your efforts.

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
ID: 6392774
Hi Mike,
I did a uninstall D4 and then re installed it  again.
Now I have no TWebBrowser. Maybe I never had it in the first place.


But that is OK,
I guess,
Delphi3
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 6907062
Please update the expert here who have so willingly stepped in to help you, since much time has passed since your last comments, and Email notifications may not have been generated to the participating experts here due to some problems at that time.  If you've been helped, accept the respective question by that expert to grade and close it.

Somewhat off-topic, but important.

****************************** ALERT********************************
WindowsUpdate - Critical Update alert March 28, 2002 from Microsoft
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/ms02-015.asp
Synopsis:
Microsoft Security Bulletin MS02-015  
28 March 2002 Cumulative Patch for Internet Explorer
Originally posted: March 28, 2002
Summary
Who should read this bulletin: Customers using Microsoft® Internet Explorer
Impact of vulnerability: Two vulnerabilities, the most serious of which would allow script to run in the Local Computer Zone.
Maximum Severity Rating: Critical
Recommendation: Consumers using the affected version of IE should install the patch immediately.
Affected Software:
Microsoft Internet Explorer 5.01
Microsoft Internet Explorer 5.5
Microsoft Internet Explorer 6.0

Thought you'd appreciate knowing this.
":0)
Asta
0
 
LVL 27

Expert Comment

by:Asta Cu
ID: 6907066
By the way, this question still sits in the OPEN QUESTION QUEUE, you may need Moderator help to determine why.
0
 
LVL 4

Author Comment

by:delphi3
ID: 6907135
astaec,

I have accepted the answer and awarded the points as noted above. Then why  is it standing so naked that you noticed it?
I think that all this happened when the EE system was in disarray.
If the points have not been awarded then I award them(50).  If the grade has not been given then It should have been a 'B'.
I want to get this Q to have it's clothes on. :) a closure!!!

Delphi3
0
 
LVL 4

Author Comment

by:delphi3
ID: 6907470
astaec,

I have accepted the answer and awarded the points as noted above. Then why  is it standing so naked that you noticed it?
I think that all this happened when the EE system was in disarray.
If the points have not been awarded then I award them(50).  If the grade has not been given then It should have been a 'B'.
I want to get this Q to have it's clothes on. :) a closure!!!

Delphi3
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
PDF library for Delphi 2 105
calling Tcolordialog in dll make the form disappear 8 103
Making delphi communicate with a c# service 16 89
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now