Hello,
Wondering if anyone has tried to use Beautiful Soup with FME desktop.
Thanks.
Hello,
Wondering if anyone has tried to use Beautiful Soup with FME desktop.
Thanks.
Best answer by mark2catsafe
Yes, I believe we've used it with FME before. There used to be an article on the knowledgebase, but it was removed because it became out of date. In case it's of use, the following is the content of that article:
_____
Parsing HTML files with Beautiful Soup for Python
BeautifulSoup for Python is a powerful parser for HTML/XML. It can serve well as a replacement of the standard FME tools such as StringSearcher (aka Grepper) or StringReplacer. Their use for HTML parsing is shown on HTTPFetcher page.
The attached example takes an HTML page containing a few tables. Some of them are used for design purposes, the other contain useful information about extra cost plug-ins for FME. BeautifulSoup scans through them, takes only necessary tables (<table> tags), searches for rows (<tr> tags) and cells (<td> tags) turning them accordingly into feature types, features, and attributes.
Then FME itself takes care about exposing and renaming attributes, cleaning and replacing attribute values where necessary.
In order to use BeautifulSoup, Python 2.3 or higher should be installed (find more details here). BeautifulSoup.py should be placed either into \\Python24\\Lib\\site-packages (to use it with any workspace) or together with the workspace calling it (to make it portable).
Note that HTML can have a very complex structure, and it's impossible to use one Python script for any HTML file. Use this example as a simple introduction into HTML parsing.
Refer to BeautifulSoup documentation for more details about HTML parsing.
_____
Sadly, the example that is mentioned in the article has also been removed and isn't available. But I hope the above helps in some way
Mark
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.