* * *

Author Topic: How to get a string data from a web page??  (Read 4158 times)

lestroso

  • Jr. Member
  • **
  • Posts: 53
How to get a string data from a web page??
« on: May 05, 2017, 06:28:03 pm »
Hi,
i'm trying to get a string from a specific web address...

in other words...i need a little script to find a string ...for example like "Summary"..or another word...and get from a specific web address ..like "www.google.com"...it's only an example...and if the string is found....i need an show message on screen for confirmation....

Can somebody help me with a little script???Thanks a lot in advance
Lestroso :-[
« Last Edit: May 19, 2017, 07:18:56 pm by lestroso »

wp

  • Hero Member
  • *****
  • Posts: 3731
Re: How to get a string data from a web page??
« Reply #1 on: May 05, 2017, 06:42:38 pm »
Use the fasthtmlparser which comes with fpc. See http://forum.lazarus.freepascal.org/index.php/topic,35980.msg239199.html#msg239199 for an example of its usage which you certainly can generalize to your application
Lazarus trunk / fpc 3.0.0 / Win32

lestroso

  • Jr. Member
  • **
  • Posts: 53
Re: How to get a string data from a web page??
« Reply #2 on: May 07, 2017, 08:02:19 am »
Thanks to you....but i can't find any reference from the link you gave me....can somebody help me with a little script??? thanks,
lestroso :-[

Thaddy

  • Hero Member
  • *****
  • Posts: 4432
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

lestroso

  • Jr. Member
  • **
  • Posts: 53
Re: How to get a string data from a web page??
« Reply #4 on: May 07, 2017, 03:08:33 pm »
Thanks Thaddy,  but that example don't apply to me, because i don't want to make a browser...i only need to find a string in a specific web page....
can somebody tell me how i can with a little script?? thanks a lot to everybody...

Lestroso  :-[

avra

  • Hero Member
  • *****
  • Posts: 1085
    • Additional info
Re: How to get a string data from a web page??
« Reply #5 on: May 07, 2017, 03:22:04 pm »
i only need to find a string in a specific web page
If your search string is not part of HTML page elements, then the most simple way would be to use http download to get that page, and then use Pos() to find if string is inside. If your search string might be part of other HTML page elements then you need to do real parsing as suggested, or at least manually extract text inside useful tags and then do the search.
If you do not do it manually and instead learn some parsing lib then it will pay of in the long term.
ct2laz - Easily convert components and projects between Lazarus and CodeTyphon

wp

  • Hero Member
  • *****
  • Posts: 3731
Re: How to get a string data from a web page??
« Reply #6 on: May 07, 2017, 03:39:28 pm »
that example don't apply to me, because i don't want to make a browser...i only need to find a string in a specific web page....
can somebody tell me how i can with a little script?? thanks a lot to everybody...
No that example exactly applies, it is NOT for a browser and it IS for finding a string in a specific web page, you just have to make a few modifications. But you don't even try...
Lazarus trunk / fpc 3.0.0 / Win32

lestroso

  • Jr. Member
  • **
  • Posts: 53
Re: How to get a string data from a web page??
« Reply #7 on: May 08, 2017, 09:42:56 pm »
Dear wp, thanks and thanks to everybody,

i have downloaded a the simple demo hmltxt....but unfortunetly this example don't work... can somebody tell me please a little code??

in other words, i need to retrieve : strong sell ,sell,buy, strong buy,neutral in this web address on 5 minute on summary eurusd...in this site :
https://www.investing.com/technical/technical-summary
and get if there a string of them and give me a show message...thanks a lot

best regards,
Lestroso :-[

wp

  • Hero Member
  • *****
  • Posts: 3731
Re: How to get a string data from a web page??
« Reply #8 on: May 09, 2017, 12:19:26 am »
In the attachment there's a modified version of the mentioned demo program. It reads the web site that you mentioned and extracts the table with the currency data. I did not understand in detail what you want to extract, but you hopefully can continue from here by yourself.

Note that the program requires the openssl dlls in the folder with the exe file in order to be able to read the https - if you don't have them look at https://indy.fulgan.com/SSL/. Note also that the code used is not very sophisticated and works only with the url you provided.

I hope you are not playing fools with me and I did your home works...

Lazarus trunk / fpc 3.0.0 / Win32

sky_khan

  • Guest
Re: How to get a string data from a web page??
« Reply #9 on: May 09, 2017, 12:29:43 am »
@lestroso
I will not answer the question. I see that 6 months ago you have asked how to fetch data from an URL and now you ask how to extract something from HTML?
I would have expected you to learn one or two things in last 6 months.  Sorry, I just had to say this. You keep going...

Thaddy

  • Hero Member
  • *****
  • Posts: 4432
Re: How to get a string data from a web page??
« Reply #10 on: May 09, 2017, 06:52:56 am »
He is rather stubborn. I pointed him to wp's excellent example and he does not understand it at all..
wp confirmed that he should test it better and should have a look how it works because it does exactly what he wants.
He obviously did not.

Difficult to give advice if they don't listen.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Handoko

  • Hero Member
  • *****
  • Posts: 1514
  • My goal: build my own game engine using Lazarus
Re: How to get a string data from a web page??
« Reply #11 on: May 09, 2017, 07:34:27 am »
Wow, just compiled the code and it worked.  :D

I ever wanted to learn to code web related things, but it sounds complicated so I never really explorer the field. The code from Thaddy's link is so simple, easy to understand and no need to install any packages. It's really a good start for a newbie like me, now the fun begins.

Thanks Thaddy for link and all other people especially the TS who bring up this topic.

lestroso

  • Jr. Member
  • **
  • Posts: 53
Re: How to get a string data from a web page??
« Reply #12 on: May 09, 2017, 05:22:33 pm »
i'm sorry for my questions about this topic...for me is very important...i'm lazarus beginner...
Dear wp, i tryed your  software....but lazarus give me an error when execute your software....the compile was fine....but give me this errror: Could not inizialize OpenSSl Library....

any ideas?? can you help me?
best regards, lestroso :-[

wp

  • Hero Member
  • *****
  • Posts: 3731
Re: How to get a string data from a web page??
« Reply #13 on: May 09, 2017, 05:24:38 pm »
Please read what I wrote in reply #8, 2nd paragraph.
Lazarus trunk / fpc 3.0.0 / Win32

lestroso

  • Jr. Member
  • **
  • Posts: 53
Re: How to get a string data from a web page??
« Reply #14 on: May 09, 2017, 05:43:16 pm »
It' ok...i have had success with your demo wp.... thank again it works now fine....

Thanks Lestroso,  :D :D :D
« Last Edit: May 09, 2017, 05:47:26 pm by lestroso »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus