Lazarus: Get HTML of a Website
Question by Guest | 2015-03-23 at 09:56
I would like to read out the HTML code of an Internet page using Lazarus (URL is given). It is not about displaying the HTML in a browser complement or something like that. I am only interested in the content because I need some information from a webpage for my application.
Is there any very simple light-weight method I can use? I do not want to include one of those huge Internet libraries into my program, because I really only need this function. I prefer a solution that is platform independent.
Related Topics
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
jQuery: Load and Replace DIV Content with clicking Links
Tutorial | 0 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
PHP: Sending an E-Mail
Tutorial | 0 Comments
HTML: Difference between ID and CLASS
Info | 0 Comments
HTML: No line break between particular words
Tip | 0 Comments
PHP: Remove all HTML Tags from String
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
You can just use fphttpclient which is part of the fcl-web package and therefore automatically included in FreePascal and Lazarus without need to install additional components or libraries. You just have to add "fphttpclient" to the uses clause of your unit.
Here is a simple example:
In this example, we are picking the HTML code from example.com in order to show it within a memo. For this, we are using the class function SimpleGet of TFPCustomHTTPClient which allow us to do the job within only one line of code.
Of course, you can also go the detailed way:
In both cases, the result is the same. The second example is a little bit longer but you can use it as a basis if you would like to extend the code in some way.
2015-03-23 at 12:37