Solved

Getting the next HTML page

Posted on 2001-08-09
11
164 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 4

Author Comment

by:delphi3
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

7 Experts available now in Live!

Get 1:1 Help Now