algorithmic modeling for Rhino
is there any smaprt way to parse html tables intot trees.
I am looking to somehow extract tags and what is inside tags in html
through grasshopper, is it possible to write tag search?
It is possible, but I think you'll have to write a lot of code in VB/C# components to do it.
Please, if it possible, can you make a text serch component - to find a symbol or a text in the search text and figure out the index of first symbol of the search in the source text?
This will be so cool and handle...
I am just wondering if anyone has added any HTML parsing components since this thread was written. If not, I will consider writing some in python and publishing them, but my programming background is not terribly impressive. Before I undertake this, however, I would like to make sure that nothing else is available at this point in time... does anyone know of any plugins that offer this type of functionality? How about any plugins that extend GH's basic string manipulation?
I don't think so.
I recommend you to use lxml.html module in python, which parses html. With the python component in grasshopper, you can use lxml.html in grasshoppr
Thanks, Philipp. I'll give it a look!
i've done this for a project long time ago. It's pretty simple with C#, when you use a library called "HTML Agility Pack". I've attached a GH Definition with this library and a really short code example.
string source = (new System.Net.WebClient()).DownloadString(url);
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
HtmlNode table = doc.GetElementbyId("installers");
DataTree result = new DataTree();
foreach(HtmlNode row in table.Descendants("tr"))
GH_Path path = new GH_Path(table.Descendants("tr").ToList().IndexOf(row));
foreach(HtmlNode column in row.Descendants("td"))
A = result;
Thats it. I hope this helps...
The GH definition ...would not upload with the first reply hm :-/
I tried using your component and for some reason whatever I do the C# component fails to import the HtmlAgilityPack.dll library. Any idea why this could be happening?
i just reopened the script and it's working as it was in 2015. Please check following things:
1.) HtmlAgilityPack.dll requires at least .Net Framework 4.0
2.) Update to the latest Grasshopper and Rhinoceros version.
3.) Unblock the HtmlAgilityPack.dll if necessary, by opening properties (right-click in file browser and click "unblock" on properties dialog)
4.) Save the GH and DLL file in a different directory...e.g Documents and try to run the script again.
Hope this works,
Thanks Florian - #3 was the problem, I had to "unblock" the library. This works great! Thanks for your help.
Also @William Carroll - Eagles Fly High.