Element Offset

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Created page with "$Element Offset is a Browser Function. This function allows you to return just one of the elements when the element selector matches more than one eleme...")
 
Line 7: Line 7:
 
== Example ==
 
== Example ==
  
  load html("<b>One</b>
+
  <pre>load html("<b>One</b>
 
  </br>
 
  </br>
 
  <b>Two</b>
 
  <b>Two</b>
Line 18: Line 18:
 
  ")
 
  ")
 
  set(#my item, $scrape attribute($element offset(<tagname="b">, 4), "innertext"), "Global")
 
  set(#my item, $scrape attribute($element offset(<tagname="b">, 4), "innertext"), "Global")
 +
</pre>
  
 
The script above create an example of how the element offset function can come in handy. Notice that there are two items (the word Three) in the load html command that are identical. The script is attempting to scrape an item that is identical to another item on the page. In order to make sure that the item returned is the item that was selected with the element selector, the element offset function appears and specifies the item using a tagname and a number specific to the item.
 
The script above create an example of how the element offset function can come in handy. Notice that there are two items (the word Three) in the load html command that are identical. The script is attempting to scrape an item that is identical to another item on the page. In order to make sure that the item returned is the item that was selected with the element selector, the element offset function appears and specifies the item using a tagname and a number specific to the item.
  
 
Running the script will return only one item in the variable.
 
Running the script will return only one item in the variable.

Revision as of 19:33, 28 November 2012

$Element Offset is a Browser Function.

This function allows you to return just one of the elements when the element selector matches more than one element (i.e. several elements share the exact same attributes).

It will appear automatically if you are trying to select an item that is identical to another item on the page.

Example

load html("<b>One</b>
 </br>
 <b>Two</b>
 </br>
 <b>Three</b>
 </br>
 <b>Four</b>
 </br>
 <b>Three</b>
 ")
 set(#my item, $scrape attribute($element offset(<tagname="b">, 4), "innertext"), "Global")
 

The script above create an example of how the element offset function can come in handy. Notice that there are two items (the word Three) in the load html command that are identical. The script is attempting to scrape an item that is identical to another item on the page. In order to make sure that the item returned is the item that was selected with the element selector, the element offset function appears and specifies the item using a tagname and a number specific to the item.

Running the script will return only one item in the variable.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox