Jump to content
UBot Underground

[Tutorial] What Are Element Offsets


Recommended Posts

Hey

 

Simple tutorial for some of the beginners to ubot,usually it takes a while to get what an element offset is,this may make it a bit clearer

 

Say a page has two p tags

<p>First</p>

<p>Second</p>

 

The total Element offsets for the above,for the tagname p is 2,offset 0 is "First",1 is the second p tag

 

Basically they are just a single list item from an entire list of matching scrapes,example below makes a simple function for returning the total offsets so we can loop through them and scrape

 

So we will scrape every href on the page and text inside of the myClass class

define $totalOffsets(#Element) {
    add list to list(%total,$scrape attribute($element from text(#Element),"outerhtml"),"Don\'t Delete","Local")
    return($list total(%total))
}
load html("<a href=\"example1.com\">Example1</a>
<a href=\"example2.com\">Example2</a>


<div class=\"myClass\"><p>some text here1</p></div>
<div class=\"myClass\"><p>some text here2</p></div>
<div class=\"myClass\"><p>some text here3</p></div>")
wait for browser event("Everything Loaded","")
comment("2 a tags on page")
comment("3 \"myClass\" on page")
set(#position,0,"Global")
loop($totalOffsets("<tagname=\"a\">")) {
    alert($scrape attribute($element offset(<tagname="a">,#position),"href"))
    increment(#position)
}
set(#position,0,"Global")
loop($totalOffsets("<class=\"myClass\">")) {
    alert($scrape attribute($element offset(<class="myClass">,#position),"innertext"))
    increment(#position)
}
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...