deliter 203 Posted February 10, 2016 Report Share Posted February 10, 2016 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) } 1 Quote Link to post Share on other sites
Ptrick125 45 Posted February 11, 2016 Report Share Posted February 11, 2016 Element offsets are pretty crucial when you have to deal with a weird page setup, so it's really important to know how to use them. Good post with the source code 1 Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted February 11, 2016 Report Share Posted February 11, 2016 Great tut!thanks for sharing!! 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.