You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chen Bingxuan edited this page Aug 19, 2016
·
1 revision
Data.HTML.Selector provides CSS style tag selector, enabling quick information filtering and extracting.
I didn't know a lot about CSS selectors when I was writing this module. So this module is a little too easy.
This is the selector, including tag name selector, class selector and id selector. However, it doesn't support selecting by attributes.
Data.HTML.Selector functions
createSelector::String->Selector
create a selector by a CSS style selector string
applySelector::Selector->Tag->[Tag]
apply a selector to a tag, and return the children tags of that tag which match the condition
select::String->Tag->[Tag]
directly apply a string-typed selector to a tag
findByTag::String->Tag->[Tag]
find the children tags of a specific tag by its tag name
findById::String->Tag->[Tag]
find the children tags of a specific tag by its id
findByClass::String->Tag->[Tag]
find the children tags of a specific tag by its class
Data.HTML.Selector operators
(||>)::[Tag]->Selector->[Tag]
This operator works as a pipe filter. You can feed a list of tags to a selector, and the returned value is still a list of tags. So you can feed the results to another selector. Like: tags ||> selector1 ||> selector2, the result is the tags filtered by both selector1 and selector2.
(|>>)::[Tag]->Selector->[Tag]
Similar to (||>), except that it also searches for the children tags of the listed tags, while (||>) only searches the direct tags in the list, not their children.