Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

KRL makes extensive use of jQuery selectors in actions to position, modify and insert elements into web pages.5 The  The query() operator allows jQuery selectors to be used inside a KRL ruleset to extract data from Web pages. (This is often called screen scraping.)
The query() operator works on HTML strings or on arrays of HTML strings. The HTML is usually loaded by the ruleset using a dataset declaration:
dataset r_html:HTML <- "http://www.htmldog.com/examples/darwin.html"
dataset q_data:HTML <- "http://www.htmldog.com/examples/tablelayout1.html"
The :HTML after the name of the dataset is a hint to KRL that it can skip the JSON parsing stage that is the default when reading data sets.
The query() operator takes an argument that is a jQuery selector string, a comma-separated jQuery string, or an array of jQuery selector strings. query()supports only a subset of the jQuery selectors for now:

...