LATEST VERSION 1.6 (29.09.2016)


UBrowser is an UObject created to get information from websites or RSS channels. With this module you will be able to browse web pages using XML notation. UBrowser enables you to browse all nodes contained in the source code and get their names, atributes and text.

UBrowser is based on POCO library. The POCO C++ Libraries are a collection of open source C++ class libraries that simplify and accelerate the development of network-centric, portable applications in C++. The libraries integrate perfectly with the C++ Standard Library and fill many of the functional gaps left open by it. Their modular and efficient design and implementation makes the POCO C++ Libraries extremely well suited for embedded development, an area where the C++ programming language is becoming increasingly popular, due to its suitability for both low-level (device I/O, interrupt handlers, etc.) and high-level object-oriented development. 

For every new data request, the source is subjected to tidying process. Tidy is able to fix up a wide range of problems and to bring to your attention things that you need to work on yourself. Each item found is listed with the line number and column so that you can see where the problem lies in your markup. Tidy won't generate a cleaned up version when there are problems that it can't be sure of how to handle. These are logged as "errors" rather than "warnings". More recently, Tidy supports HTML5 and clean up HTML exported from Google Docs.


UBrowser was compiled with all the shared libraries (all included in package). Copy them to the uobjects folder or set path in system environment variable (PATH).

  • libiconv.dll
  • libtidy.dll
  • PocoFoundation.dll
  • PocoNet.dll
  • PocoUtil.dll
  • PocoXML.dll

You can also use a static linking option. In this case you need to download POCO, libconv, libtidy libraries and add preprocessor definitions (USING_STATIC_LIBICONV, POCO_STATIC). You can also download all the precompiled projects here (POCOlibconv, libtidy).

How it works

Example 1 - latest news

Let's consider, that we would like to get some news from BBC web (  BBC provides us with a very extensive website, full of graphics (left part of Fig. 1). To reduce useless content we can force our browser to present itself as a mobile version. For this purpose we can use UBrowser.userAgent slot of the module to set a browser name string. The list of user agent strings you can find here In this example we use the iPhone browser name.

Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.

Now, the server automatically redirects us to the mobile version of the website (in this case to Notice, that BBC web looks more legible but still full of content (right part of Fig. 1). Next, you need to look at the page source and find right node name (eg. html tag). The fewer tags the easier it is. Please note that you can check it with your regular browser. You just need to install UserAgent plugin (add-on) which is available for many browsers (Chrome, FireFox, Opera,...)

ubrowser1         ubrowser2
Fig. 1 Example website (regular version on the left, mobile version on the right)

The next step is to find a node (part of code) with news content. You can check two slots with content UBrowser.rawContent (contains a raw response from server) or UBrowser.content (data formatted for better view). You can use echo function or save data to a file.

UBrowser.SaveContent("content.txt",1); - 1 means that you choose formatted content.

The example below shows how the content should look like. Note that right column contains formatted data, where the first number indicates node/attribute number, second means type of node (1 - node, 2 - attribute, 3 - text,...).

UBrowser.rawContent UBrowser.content

<html lang="en-GB">
<meta name="generator"
content="HTML Tidy for HTML5" />
<!-- Barlesque 2.51.6 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description"
content="Breaking news, sport, TV, radio and a whole lot more." />
<meta name="keywords" content="BBC,,, iPlayer, BBCi" />
<title>BBC - Homepage</title>


<a href="/news/world-africa-24417099"
title="US special forces 'in Somalia raid'" class="hero">
<div class="unwrap">
<img src="/"
alt="US Navy Seals. File photo" />
<span class="title">US special forces 'in Somalia raid'</span>
<p class="summary">US special forces targeted a leader of the
al-Shabab Islamist group in Somalia in response to Kenya's Westgate attack, US officials say.</p></div>
<a href="/news/world-middle-east-24415673"
title="Attack kills dozens of Iraq pilgrims" class="hero">
<div class="unwrap">
<span class="title">Attack kills dozens of Iraq pilgrims</span>
<p class="summary">Dozens die and many more are injured in an attack on Shia pilgrims in Baghdad, amid a fresh round of violence across Iraq.</p>

1 |9| #document:
2 |1| html:
0 |2| lang="en-GB"
3 |1| head:
4 |1| meta:
0 |2| name="generator"
1 |2| content="HTML Tidy for HTML5"
5 |8| #comment: Barlesque 2.51.6
6 |1| meta:
0 |2| http-equiv="Content-Type"
1 |2| content="text/html; charset=utf-8"
7 |1| meta:
0 |2| name="description"
1 |2| content="Breaking news, sport, TV, radio and a whole lot more."
8 |1| meta:
0 |2| name="keywords"
1 |2| content="BBC,,, iPlayer, BBCi"
9 |1| title:
10 |3| #text:BBC - Homepage


78 |1| article:
79 |1| a:
0 |2| href="/news/world-africa-24417099"
1 |2| title="US forces 'hit Islamists in Africa'"
2 |2| class="hero"
80 |1| div:
0 |2| class="unwrap"
81 |1| img:
0 |2| src="/"
1 |2| alt="US Navy Seals. File photo"
82 |1| span:
0 |2| class="title"
83 |3| #text:US forces 'hit Islamists in Africa'
84 |1| p:
0 |2| class="summary"
85 |3| #text:US special forces have carried out two separate raids in Somalia and Libya targeting senior Islamist militants, American officials say.
86 |1| article:
87 |1| a:
0 |2| href="/news/world-middle-east-24415673"
1 |2| title="Attack kills dozens of Iraq pilgrims"
2 |2| class="hero"
88 |1| div:
0 |2| class="unwrap"
89 |1| span:
0 |2| class="title"
90 |3| #text:Attack kills dozens of Iraq pilgrims
91 |1| p:
0 |2| class="summary"
92 |3| #text:Dozens die and many more are injured in an attack on Shia pilgrims in Baghdad, amid a fresh round of violence across Iraq.

Now you can use searching functions to find news text. As you can see the <article> node starts at number 78. You can perform the following:

<< UBrowser.GetByPosition(78,-1); // -1 means that you get the node value (text) not atribute parameter.


<< UBrowser.GetByPosition(78+6,-1); // +6 is an offset in the nodes tree to get the news text
>> "US special forces have carried out two separate\nraids in Somalia and Libya targeting senior Islamist militants, American officials say."

To get attribute value run this command with 0 as the second argument 

<< UBrowser.GetByPosition(78+6,0); // +6 it's an offset in the nodes tree, 0 means first attribute value. 
>> "summary"

to get next piece of news use additional offset +7

<< UBrowser.GetByPosition(78+6+7,-1); // +7 next news
>> "Dozens die and many more are injured in an\nattack on Shia pilgrims in Baghdad, amid a fresh round of violence across Iraq."
 and so on. Another searching option is getting text by pattern. Use function UBrowser.FindPosition("node_name",["list_of_attributes"]); and try to find a node with the name <article>
UBrowser.FindPosition("article",[""]); // empty list of attributes [""] means, that we are looking for a node with no attributes. 

Another possibility is 

UBrowser.FindPosition("article",["-1"]); // when you put "-1" as the attribute list, it means that you are looking for any <article> nodes (with or without attributes).

After this command you receive a list of positions of nodes with the name <article>

>> [[78, -1], [86, -1], [93, -1], [98, -1], [110, -1], [131, -1], [139, -1], [146, -1], [151, -1]]

In the list of attributes you can only put a name or name and value eg. attribute="value" 

<< UBrowser.FindPosition("article",["src"]); 
<< UBrowser.FindPosition("article",["alt=\"US Navy Seals. File photo\""]);

The last option is to find element by its full path. It is simillar to the GetByPosition, but in this case you need to insert a path. Consider the following example:

<< UBrowser.GetTextByPath("/html/body/div[1]/div[1]/div/section/article/a/div/p"); // use only plain XPath format 
>> "US special forces have carried out two separate\nraids in Somalia and Libya targeting senior Islamist militants, American officials say."
<< UBrowser.GetAtributesByPath("/html/body/div[1]/div[1]/div/section/article/a"); // use only plain XPath format, returns list of lists in format [["name1","value1"],["name2","value2"],...]
>> [["href", "/news/world-africa-24417099"], ["title", "US commandos hit Islamists in Africa"], ["class", "hero"]]

There is also a different function available to get full nodes information. It returns a lists of node names, attributes and texts.

browser.GetElementsByPath("/html/body/div[1]/div[1]/div/section/article/a/div");- use only plain XPath format 
>> [["img", "span", "p"], ["src=
alt=US Navy Seals. File photo ", "class=title ", "class=summary "], ["", "US commandos hit Islamists in Africa", "US special forces have carried out two separate\nraids in Somalia and Libya targeting senior Islamist militants American officials say."]]

Example 2 - weather forecast

Traversing the node tree is a little complicated. It is much better, if the sought information is provided by an RSS channel. First of all, the content is very modest and there is a big chance that syntax will be quite stable. When you set the paths in your urbiscripts once, they should be valid for a long time. Let's consider weather forecast as an example. One of the best weather forecast providers is YAHOO. All the needed data about Yahoo Weather RSS Feed can be found here

To get weather information for a specific location, just use the following link:*%20from%20weather.forecast%20where%20woeid=LOCATION%20and%20u=%27T%27&format=xml

, where LOCATION is a WOEID number (the WOEID parameter is required). To determine your location number use this page The last parameter - T - indicates units for temperature (case sensitive) f: Fahrenheit, c: Celsius. Let's see an example for Wroclaw, POLAND, the link is*%20from%20weather.forecast%20where%20woeid=526363%20and%20u=%27c%27&format=xml

You should receive this rss code

<query xmlns:yahoo="" yahoo:count="1" yahoo:created="2016-09-29T13:15:22Z" yahoo:lang="pl-PL">
<yweather:units xmlns:yweather="" distance="km" pressure="mb" speed="km/h" temperature="C"/>
<title>Yahoo! Weather - Wroclaw, Lower Silesia, PL</title>
<description>Yahoo! Weather for Wroclaw, Lower Silesia, PL</description>
<lastBuildDate>Thu, 29 Sep 2016 03:15 PM CEST</lastBuildDate>
<yweather:location xmlns:yweather="" city="Wroclaw" country="Poland" region=" Lower Silesia"/>
<yweather:wind xmlns:yweather="" chill="77" direction="230" speed="22.53"/>
<yweather:atmosphere xmlns:yweather="" humidity="36" pressure="33965.49" rising="0" visibility="25.91"/>
<yweather:astronomy xmlns:yweather="" sunrise="6:52 am" sunset="6:31 pm"/>
<title>Yahoo! Weather</title>
Conditions for Wroclaw, Lower Silesia, PL at 02:00 PM CEST
<geo:lat xmlns:geo="">51.10804</geo:lat>
<geo:long xmlns:geo="">17.026699</geo:long>
<pubDate>Thu, 29 Sep 2016 02:00 PM CEST</pubDate>
<yweather:condition xmlns:yweather="" code="26" date="Thu, 29 Sep 2016 02:00 PM CEST" temp="25" text="Cloudy"/>
<yweather:forecast xmlns:yweather="" code="26" date="29 Sep 2016" day="Thu" high="24" low="15" text="Cloudy"/>
<yweather:forecast xmlns:yweather="" code="28" date="30 Sep 2016" day="Fri" high="24" low="15" text="Mostly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="28" date="01 Oct 2016" day="Sat" high="20" low="11" text="Mostly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="28" date="02 Oct 2016" day="Sun" high="18" low="10" text="Mostly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="30" date="03 Oct 2016" day="Mon" high="17" low="10" text="Partly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="30" date="04 Oct 2016" day="Tue" high="16" low="8" text="Partly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="30" date="05 Oct 2016" day="Wed" high="13" low="4" text="Partly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="30" date="06 Oct 2016" day="Thu" high="13" low="5" text="Partly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="30" date="07 Oct 2016" day="Fri" high="15" low="6" text="Partly Cloudy"/>
<yweather:forecast xmlns:yweather="" code="30" date="08 Oct 2016" day="Sat" high="14" low="6" text="Partly Cloudy"/>
<![CDATA[<img src="/"/> <BR /> <b>Current Conditions:</b> <BR />Cloudy <BR /> <BR /> <b>Forecast:</b> <BR /> Thu - Cloudy. High: 24Low: 15 <BR /> Fri - Mostly Cloudy. High: 24Low: 15 <BR /> Sat - Mostly Cloudy. High: 20Low: 11 <BR /> Sun - Mostly Cloudy. High: 18Low: 10 <BR /> Mon - Partly Cloudy. High: 17Low: 10 <BR /> <BR /> <a href="/*">Full Forecast at Yahoo! Weather</a> <BR /> <BR /> (provided by <a href="/" >The Weather Channel</a>) <BR /> ]]>
<guid isPermaLink="false"/>

And that is everything you need. To choose particular pieces of information just use the following commands:

<< UBrowser.GetAtributesByPath("/query/results/channel/yweather:wind"); // information about wind,
>> [["chill", "3"], ["direction", "0"], ["speed", "3.22"]]
<< UBrowser.GetAtributesByPath("/query/results/channell/yweather:atmosphere"); // about atmosphere,
>> [["humidity", "87"], ["visibility", "9.99"], ["pressure", "1015.92"], ["rising", "0"]]
<< UBrowser.GetAtributesByPath("/query/results/channel/item/yweather:condition")[2][1]; // current temperature,
>> "3"

See UBrowser in action

Module Functions

Main functions; - create a new instance of the module,
bool = UBrowser.Go( "address" ); - go to the given address (https is not supported for now, if you need it, use Poco/NetSSL connection), returns false if any problem occurs (check console information or status slot), 
UBrowser.redirectionEnable = bool; - set on/off redirection, default if true,
double = UBrowser.status; - returns a request status code, eg. 200 - OK (1xx Informational, 2xx Success,  3xx Redirection, 4xx Client Error, 5xx Server Error, more here),
string = UBrowser.reason; - returns a request status reason eg. (status = 404, reason = "Not Found"),
string = UBrowser.address; - get a final address (after redirection), it is useful to avoid redirection in the future,
UBrowser.debug; - set debug level [0-2], 0 - no debug information, 1 - display all information from server, 2 - display 1 and rawContent, default =0. 

Cookies functions

UBrowser.cookiesEnable = bool; - set permission to read cookies, default is false (some servers provides cookies with uncompatible data format, in this case POCO hangs),
double = UBrowser.cookies - get the number of cookies and feed your robot if he is hungry :),
string = UBrowser.GetCookie( ID ); - get cookie details as string (name, comment, domain, path, max-age, httponly, version, secure, and value),

Content functions

string = UBrowser.rawContent; - get a raw server response (after tidying and encoding),
string = UBrowser.content; - get a formatted content (rawContent) in one of the following formats:
node_number | node_type | indents node_name:text,
attribute_number | node_type | indents attribute_name:attribute_value,
bool = UBrowser.SaveContent("file_name" , type); - save content to a file, type=0 save raw content, type=1 save cleaned content, type=2 save formatted content.

Node traversing and searching functions

string = UBrowser.GetTextByPath( "XPath" ); - get text of the node given path, see example 2,
[ "nodeChild1" , "nodeChild2" ,..] = UBrowser.GetNodesByPath("XPath"); - get child nodes for a given path, see example 3,
[ [ "attribute1" , "value1" ] , ["attribute2" , "value2" ],...] = UBrowser.GetAtributesByPath("XPath"); - get a list of attributes and values for given node path, see example 4,
[ [ "node1" , "node2",... ] , [ "attribute1="value1" attribute2="value2" , attribute1="value1" attribute2="value2""] , ["text1" , "text2",...] = UBrowser.GetElementsByPath("XPath"); - get a list of elements (node name, list of attributes and text), see example 5,
[ [ node_position1 , attribute_position1 ] , [ node_number2 , attribute_number2 ]] = UBrowser.FindPosition("node_name" , [ "attribute1" , "attribute=/"value/""],... ] ); - get a list of positions for a given pattern, see example 6,
string = UBrowser.GetByPosition(node_number, atribute_number); - get a text or attribute value for a given position, see example 7.

Urbiscript examples

Example 1

Set up the module.

var Global.browser =;
browser.userAgent="Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.";

Example 2

Sample code:
<html><head><title>This is title! </title></head></html>

<< browser.GetTextByPath("/html/head/title");
>> "This is title!"

Example 3

Sample code:
<html><head><title>This is title! </title></head></html>
<< browser.GetNodesByPath("/html/head"); 
>> ["title"]

Example 4

Sample code:
<html xmlns="" xml:lang="en-GB"></html>
<< browser.GetAtributesByPath("/html"); 
>> [["xmlns",""],["xml:lang","en-GB"]]

Example 5

Sample code:
<html xml:lang="en-GB"> text </html>
<< browser.GetElementsByPath("/"); 
>> [["html" ],["xml:lang=\"en-GB\""],[ "text"]]

Example 6

Sample code:
<table><tr><td valign="top"><img src="/image.gif" alt="[IMG]"></td><td><a href=""></a></td><td>&nbsp;</td></tr></table>
<< browser.FindPosition("td",["-1"]); // -1 means any node is acceptable (with or without attributes)
>> [[3,-1],[5,-1]]
<< browser.FindPosition("td",[""]); // empty list means node without attributes only
>> [[5,-1]]
<< browser.FindPosition("td",["valign"]); // find node given an attribute only
>> [[3,0]]
<< browser.FindPosition("td",["valign=\"top\""]); // find node given an attribute and a value only
>> [[3,0]]

Example 7

Sample code:
<table><tr><td valign="top"><img src="/image.gif" alt="[IMG]"></td><td><a href=""></a></td><td>&nbsp;</td></tr></table>
<< browser.GetByPosition(7,-1); // -1 means that you need the text for the given node 
>> ""
<< browser.GetByPosition(7,0); // 0 means that you need first (0) attribute value for the given node
>> ""

Example 8

This example is for YAHOO weather
browser.Go(""+_Net_Weather_location+"&u="+_Net_Weather_scale); = browser.GetAtributesByPath("/rss/channel/yweather:location")[0][1]; = browser.GetAtributesByPath("/rss/channel/yweather:location" = browser.GetAtributesByPath("/rss/channel/yweather:location")[2][1]; = browser.GetAtributesByPath("/rss/channel/yweather:units")[0][1]; = browser.GetAtributesByPath("/rss/channel/yweather:units")[1][1]; = browser.GetAtributesByPath("/rss/channel/yweather:units")[2][1]; = browser.GetAtributesByPath("/rss/channel/yweather:units")[3][1]; = browser.GetAtributesByPath("/rss/channel/yweather:wind")[0][1]; = browser.GetAtributesByPath("/rss/channel/yweather:wind")[1][1]; = browser.GetAtributesByPath("/rss/channel/yweather:wind")[2][1]; = browser.GetAtributesByPath("/rss/channel/yweather:atmosphere")[0][1]; = browser.GetAtributesByPath("/rss/channel/yweather:atmosphere")[1][1]; = browser.GetAtributesByPath("/rss/channel/yweather:atmosphere")[2][1];
var tmp_atm = browser.GetAtributesByPath("/rss/channel/yweather:atmosphere")[3][1];
if (tmp_atm == 0) = "steady";
if (tmp_atm == 1) = "rising";
if (tmp_atm == 2) = "falling"; = browser.GetAtributesByPath("/rss/channel/yweather:astronomy")[0][1]; = browser.GetAtributesByPath("/rss/channel/yweather:astronomy")[1][1]; = browser.GetAtributesByPath("/rss/channel/item/yweather:condition")[0][1]; = browser.GetAtributesByPath("/rss/channel/item/yweather:condition")[1][1]; = browser.GetAtributesByPath("/rss/channel/item/yweather:condition")[2][1];
var tmp_for = browser.GetAtributesByPath("/rss/channel/item/yweather:forecast[0]"); = [tmp_for[0][1],tmp_for[1][1],tmp_for[2][1],tmp_for[3][1],tmp_for[4][1],tmp_for[5][1]];
tmp_for = browser.GetAtributesByPath("/rss/channel/item/yweather:forecast[1]"); = [tmp_for[0][1],tmp_for[1][1],tmp_for[2][1],tmp_for[3][1],tmp_for[4][1],tmp_for[5][1]];
tmp_for = browser.GetAtributesByPath("/rss/channel/item/yweather:forecast[2]"); = [tmp_for[0][1],tmp_for[1][1],tmp_for[2][1],tmp_for[3][1],tmp_for[4][1],tmp_for[5][1]];
tmp_for = browser.GetAtributesByPath("/rss/channel/item/yweather:forecast[3]"); = [tmp_for[0][1],tmp_for[1][1],tmp_for[2][1],tmp_for[3][1],tmp_for[4][1],tmp_for[5][1]];
tmp_for = browser.GetAtributesByPath("/rss/channel/item/yweather:forecast[4]"); = [tmp_for[0][1],tmp_for[1][1],tmp_for[2][1],tmp_for[3][1],tmp_for[4][1],tmp_for[5][1]];

Example 9

This example works for most news channels, such as:
var ret =; 
var tmp_count ="item",["-1"]).size; = tmp_count; = []; = []; = []; 
for (var i=0;i<tmp_count;i++){ << browser.GetTextByPath("/rss/channel/item["+i+"]/pubDate"); << browser.GetTextByPath("/rss/channel/item["+i+"]/title"); << browser.GetTextByPath("/rss/channel/item["+i+"]/description");
// << browser.GetTextByPath("/rss/channel/item["+i+"]/description").split("<")[0];




EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 1.0, 04.04.2018

FLASH Documentation