Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2010, 12:14 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default How to read a value.

Hello,

I am trying to get the value from TWebBrowser component. The scenario is like this: I navigate a URL and the result is a small number from 1-9 and nothing else. In other words, the page shows a white/clean page with this small number at the top-left corner of TWebBrowser. How can I read this value?
__________________
Regards,
Abdulaziz Jasser

Last edited by Jasser; 08-11-2010 at 09:48 PM.
Reply With Quote
  #2  
Old 08-11-2010, 12:38 PM
mmx64 mmx64 is offline
Member
 
Join Date: Aug 2009
Posts: 58
Default

hi, i use indi to get the output of a webpage, where url is generated by me in php.
Code:
var x:string;
x:=idHTTP.get('url');
Reply With Quote
  #3  
Old 08-11-2010, 01:20 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

I don't think it will work for me. When I navigate the URL the result (the number is shown in the result html file) is a small number. How to read it?
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #4  
Old 08-11-2010, 04:26 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default

Could you give me the URL to have a look?
__________________
"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #5  
Old 08-11-2010, 04:45 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default

You could use something like this for reading between the HTML Tags.

This gets the text at the top of the main page here and puts it into an Edit...

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  num, IP, ip2: String;
  l, p1, p2: integer;
  IdHttp1: TIDhttp;
begin
  try
    IdHttp1 := TIDhttp.Create(nil);
    IdHttp1.HandleRedirects := true;
    num := IdHttp1.get('http://www.delphipages.com/forum/');
    l := Length('');
    p1 := Pos('<title>', num);
    p2 := Pos('', num);
    IP := Copy(num, p1 + l, p2 - p1 - l);
  finally
    IdHttp1.Free;
  end;
  Edit1.Text := IP;
end;
__________________
"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!

Last edited by nester261; 08-11-2010 at 05:00 PM. Reason: Error!
Reply With Quote
  #6  
Old 08-11-2010, 05:30 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  num, IP, ip2: String;
  l, p1, p2: integer;
  IdHttp1: TIDhttp;
begin
  try
    IdHttp1 := TIDhttp.Create(nil);
    IdHttp1.HandleRedirects := true;
    num := IdHttp1.get('http://www.delphipages.com/forum/');
    l := Length('[title]');
    p1 := Pos('[title]', num);
    p2 := Pos('[/title]', num);
    IP := Copy(num, p1 + l, p2 - p1 - l);
  finally
    IdHttp1.Free;
  end;
  Edit1.Text := IP;
end;
It was not letting me post the code correctly! I think the reason is that it doesn't like the HTML Tags so I have replaced them with [ ... ]
__________________
"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #7  
Old 08-11-2010, 05:49 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default

Sorry nester, but I was a way from my pc. However, I found the solution in the bellow link;

http://www.swissdelphicenter.ch/en/showcode.php?id=1112

After doing a little change to the code I was able to use "OnNavigateComplete2" event of TWebBrowser to call "WB_GetHTMLCode" procedure to get the return code.

Nester and mmx64, thanks both for trying to help...
__________________
Regards,
Abdulaziz Jasser

Last edited by Jasser; 08-11-2010 at 06:10 PM.
Reply With Quote
  #8  
Old 08-11-2010, 06:01 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default

Your welcome - glad you found a solution
__________________
"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:38 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.