how to extract text only from a tiphtmlpanel
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
dcelso · 2013-09-21 11:01
Hello to all,
In trying simulate in lazarus the next steps that you can do manualty:
in a web bronwser select all web page and copy it to clipboard
open a notepad and paste the contend.
This steps do that you can extract only the text of the web without
html format or images or any rtf format.
To do it on lazarus, I did the next in a form with only a edit, a
memo, a iphtmlpanel and a button.
When you press button, the button do the next:
open the written url of the edit in the iphtmlpanel ( using THTTPSend
from synapse4) This steps work perfectly, at the end of they you can
see in the iphtmlpanel the web page. So now.
Finally i do the next to simulate the first said
iphtmlpanel1.SelectAll;
iphtmlpanel1.CopyToClipboard;
memo1.lines.Clear;
memo1.PasteFromClipboard;
But it do not anything. seems that phtmlpanel1.SelectAll does not
select all.
Anyone have an idia to simulate it?
Thanks in advance.
----------------------------------------------------------------------
Mujie · 2013-09-25 03:16
Hi @dcelso, so what is your goal? Copy a whole web content from URL
and save it to file?
----------------------------------------------------------------------
Leledumbo · 2013-09-25 12:39
I don't know what TIpHTMLPanel implementation of CopyToClipboard do,
but probably it doesn't copy its content to clipboard as text
(probably formatted text / html / something else). You can dig in the
code, the source is yours anyway.
----------------------------------------------------------------------
Mike.Cornflake · 2013-12-31 01:25
I've just coincidently stepped through the code for CopyToClipboard,
and it does indeed just paste as normal text (which for me is great,
it's exactly what I was chasing).
When I run the following code, everything works as I expect.
Code: [Select] iphtmlpanel1.SelectAll;
iphtmlpanel1.CopyToClipboard;
Only difference between my code and OP's is I'm loading the page via
iphtmlpanel1.SetHTMLFromStr.