Versions Compared

Key

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

Functions

Code Block
languagejs
[string] p([string] p); // return an html paragraph element(<p>)
[string] br(); // return an html new line
[string] element([string] tag); // return empty tag
[string] element([string] tag, [string] innerHtml); //return and element with inner Html
[string] a([string] linkUrl); // return an <a>
[string] a([string] linkUrl, [string] title); // return an <a> with title
[string] a([string] linkUrl, [string] title, [boolean] target); // if target==true will open in new window
[string] table([StringArray] headers[],[String2dArray] rows[][]) // return a table
[org.jsoup.select.Elements] find([string] selector, [string] html) // return an element object based on the css selector

Examples

function table

...

:

Create an html table and store it into variable table

...

output after printing the variable "table"

firstsecond
ab
cd


function a

...

:

Create an html link element with title that will open in new tab

Code Block
languagejs
var link=httphtml.a("https://google.com","Google",true); 
print(link);

...

output after printing the variable "link"

Google


function find:

Will find elements that will be selected by the passed css selector, please check org.jsoup.select.Elements  api.

We're trying to print the head line news in CNN website, it's not an efficient way since CNN may change it's website structure or some of the content mat load by scripts after site loaded.

Code Block
languagejs
var cnnAsHtml=http.get("http://www.cnn.com/");
var headerElement=html.find("a.link-banner h2.screaming-banner-text", cnnAsHtml);
print(headerElement.toString());