Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Quickly Parse HTML And XML With BeautifulSoup Python Library In Delphi And C++ Windows Apps

We know how to load and display Web content or local files in Delphi using TWebBrowser. It offers support for the basic functions of a browser, such as navigate to URL, go back, go forward, along with specific events. How about the web scrapping in Delphi using the Python BeautifulSoup library? Sounds Interesting? Yes, with the help of Python4Delphi we can scrap the web pages quickly in the Delphi/C++ Builder app. This post helps to understand with sample python script.

Delphi itself has extensive XML and HTML parsing capabilities through TXmlDocument. And here is some sample code for utilizing TXmlDocument in Delphi. If you have an existing Python application though you could make use of the BeautifulSoup Python Library to parse XML and HTML in your Python code. If you need extra speed you could bring the XML or HTML data over to Delphi for faster parsing through Python4Delphi. You can use Python4Delphi a number of different ways such as:

Prerequisites.

[crayon-668b55fd87be2659376459/]

Beautiful Soup Python Library sample script details: Beautiful Soup works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work. The sample script demonstrates,

[crayon-668b55fd87be9774787853/]
<strong>BeautifulSoup Python Library Demo<strong>

Note: Samples used for demonstration were picked from here with only the difference of printing the outputs. You can check the APIs and some more samples from the same place.

You have read the quick overview of Beautiful Soup library, download this library from here and pull data out of html, xml easily in your applications. Check out Python4Delphi and easily build Python GUIs for Windows using Delphi.

Exit mobile version