helyonprime96
asked on
How to parse a text from html code in delphi?
HELLO.
Please help me!
I have html code of a website into a memo.
And the program need to search a value like pr : 500.
How can i do it?
Please help.
Here is a part of code :
<td class="td2_2"> //this is begin
8 / 10 //i need to parse this value which is different for every try
</td> //end
Help anyone please?
How can i use POS function to find value?
Please help me!
I have html code of a website into a memo.
And the program need to search a value like pr : 500.
How can i do it?
Please help.
Here is a part of code :
<td class="td2_2"> //this is begin
8 / 10 //i need to parse this value which is different for every try
</td> //end
Help anyone please?
How can i use POS function to find value?
Do you want to find "pr : 500" or "8 / 10"?
ASKER
i need to find 8 / 10
but this value is not 8 / 10 for every domain.
i need to make a function that find the text between <td class="td2_2"> and </td>..
Can you help me?
but this value is not 8 / 10 for every domain.
i need to make a function that find the text between <td class="td2_2"> and </td>..
Can you help me?
Let's say you want to find that when a button is clicked then your code goes like this:
procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
begin
str:=Memo1.Text;
repeat
delete(str,1,pos('<td class',str)+1);
showmessage(trim(copy(str,pos('>',Str)+1,pos('</td>',str)-pos('>',Str)-1)));
until pos('<td class',Str) <= 0;
end;
ASKER
thanks, it tested it, but it displays me very many texts and not that i need.
ASKER
please tell me how can i copy the numbers between
<td class="td2_2">
and
</td>
??
<td class="td2_2">
and
</td>
??
ASKER
ok.i have done some modifications and it is good.
it displays me only 3 values.
How can i do that this procedure excludes 2 values from search?
it displays me only 3 values.
How can i do that this procedure excludes 2 values from search?
If you are sure it will be in that format (i.e. <td class="td2_2"> and </td>) then:
procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
begin
str:=Memo1.Text;
repeat
delete(str,1,pos('<td class="td2_2">',str)+length('<td class="td2_2">'));
showmessage(trim(copy(str,pos('<td class="td2_2">',Str)+1,pos('</td>',str)-pos('<td class="td2_2">',Str)-1)));
until pos('<td class="td2_2">',Str) <= 0;
end;
ASKER
ok, i will test it.
can you help me with this projects :
https://www.experts-exchange.com/questions/26861257/How-to-check-google-pr-in-delphi.html
https://www.experts-exchange.com/questions/26861305/How-can-i-get-the-number-of-yahoo-links-in-delphi.html
can you help me with this projects :
https://www.experts-exchange.com/questions/26861257/How-to-check-google-pr-in-delphi.html
https://www.experts-exchange.com/questions/26861305/How-can-i-get-the-number-of-yahoo-links-in-delphi.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, code works!