How to view title,desc,keywords from a website url passed via content field in CGI app

How do I extract/view the title, description, keywords from a website url passed via content field in CGI app.

Please alter the following code to work:

Var
  sl : TStringList;
begin
  sl := TStringList.Create;
  try
    // Look up website URL past from content field.
    // Use: Request.ContentFields.Values['WEBSITE_URL']

    // Display website URL
    sl.Add(Format('Website: %s<br><br>',[Request.ContentFields.Values['WEBSITE_URL']]));

    // Extract website header title.
    sl.Add(Format('title: %s<br><br>',['????']));

    // Extract website header description
    sl.Add(Format('description: %s<br><br>',['????']));

    // Extract website header keywords.
    sl.Add(Format('keywords: %s<br><br>',['????']));

    // Past back output.
    Response.Content := sl.Text;

  finally
    sl.Free;
  end;
end;

Thankss
cjclayton
cjclaytonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

huiyueCommented:
I don't know how to settle your problem.
I see your code,but no <title></title> found.
???????
what you want?
0
Eddie ShipmanAll-around developerCommented:
You will have to "download" the URL's HTML into your app using something like
httpget or Indy's idHTTP and then parse the tags, <title> and <meta>.

0
cjclaytonAuthor Commented:
EddieShipman you are on the right track.  Do you have any code samples of this?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Eddie ShipmanAll-around developerCommented:
OK, try this out, Not sure if you can get to it if you are not registered with that group, and no, I did not find all
of the code there, I only enhanced some code I already had to get the Meta tags.
Must have mshtml (d6 and up otherwise mshtml2_tlb imported) in your uses...

procedure TForm1.ParseURL(AURL: String);
Var
  IDoc:IHTMLDocument2;
  Strm:TSTringStream;
  v:Variant;
  vTitle  : string;
  i       : Integer;
  vMeta   : IHTMLMetaElement;
  vAll    : IHTMLElementCollection;
  vElement: IHTMLElement;
begin
  Memo1.Clear;
  Strm:=TSTringStream.create('');
  Idhttp1.Get(AURL,strm);
  Idoc:=CreateComObject(Class_HTMLDocument) as IHTMLDocument2;
  IDoc.designMode:='on';
  while IDoc.readyState<>'complete' do
    Application.ProcessMessages;
  v:=VarArrayCreate([0,0],VarVariant);
  v[0]:= Strm.datastring;
  IDoc.write(PSafeArray(System.TVarData(v).VArray));
  IDoc.designMode:='off';
  while IDoc.readyState<>'complete' do
    Application.ProcessMessages;

  vTitle := iDoc.Title;
  Memo1.Lines.Add(vTitle);
  Memo1.Lines.Add('');
  vAll := iDoc.all;
  for i:=0 to vAll.Length-1 do
  begin
    vElement:= vAll.item(i, varEmpty) as IHTMLElement;

    if (vElement <> nil) and (vElement.Tagname='META') then
    begin
      vMeta := vAll.item(i, varEmpty) as IHTMLMetaElement;
      if (vMeta.httpequiv='Keywords') or (vMeta.httpequiv='') then
      begin
        Memo1.Lines.Add(vMeta.content);
      end;
    end;
  end;
  IDoc := nil;
  Strm.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ParseURL('http://groups.yahoo.com/group/delphi-webbrowser/messagesearch?query=meta%20keywords');
end;

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cjclaytonAuthor Commented:
I'm only using Delphi 5.  How do I get mshtml2_tlb imported working.  Where do I download it from and how do I install it?
0
Eddie ShipmanAll-around developerCommented:
From the main menu select Project->Import Type Library.
When the dialog comes up go down in the list until you find
"Microsoft HTML Object Library", then click Install and install
it into whatever package you want.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.