Siegfried88 3 Posted February 16, 2015 Report Share Posted February 16, 2015 Hey all, I am at my wits end on this one. For almost a year I have been having limited success when it comes to using the "$scrape attribute" function in UBot. I have almost always defaulted to using "$find regular expression" after wasting hours with the former. However, I know I am holding myself back. I have finally made some examples below to illustrate my thought process. I am hoping that some savvy Ubotters here can both tell me what I am actually telling Ubot to do, why I am thinking about this the wrong way, and what should the code look like to get the results I am expecting. I pretty certain there is some overlap as to the 'error of my ways'. Also, please excuse the bouncing back from #variable to %list, depending on whether I was expecting one or more return values. Overall, "e01", "e02", etc. stand for "example 1", "example 2", etc. I hope that makes sense. I understand the results of example 1 and 4, but not the others. Lastly, I have gone over the example on http://wiki.ubotstudio.com/wiki/Element_Sibling . While I partially understand it, I do not know why it requires nesting one "$element sibling" in another. Thanks in advance! on load("Bot Loaded") { load html("<html> <body> <p name=\"p1\"> <h1 name=\"p1h1\">P1H1</h1> <h2 name=\"p1h2\">P1H2</h2> <h3 name=\"p1h3\">P1H3</h3> <div name=\"p1d1\"> P1D1 <p name=\"p1d1Subp1\"></p> <p name=\"p1d1Subp2\"></p> <p name=\"p1d1Subp3\"></p> </div> <div name=\"p1d2\"> P1D2 <p name=\"p1d2Subp1\"</p> <p name=\"p1d2Subp2\"</p> <p name=\"p1d2Subp3\"</p> </div> </p> <p name=\"p2\"> <h1 name=\"p2h 1\">P2H1</h1> <h2 name=\"p2h 2\">P2H2</h2> <h3 name=\"p2h 3\">P2H3</h3> <div name=\"p2d1\"> P2D1 <p name=\"p2d1Sub p1\"></p> <p name=\"p2d1Sub p2\"></p> <p name=\"p2d1Sub p3\"></p> </div> <div name=\"p2d2\"> P2D1 <p name=\"p2d2Subp1\"></p> <p name=\"p2d2Subp2\"></p> <p name=\"p2d2Subp3\"></p> </div> </p> </body> </html>") } divider set(#e01,$scrape attribute(<name="p1h1">,"tagname"),"Global") add list to list(%e02,$scrape attribute($element child(<name="p1d1">),"name"),"Delete","Global") set(#e03,$scrape attribute($element parent(<name="p1d1">),"name"),"Global") set(#e04,$scrape attribute($element offset(<name="p1h1">,0),"innertext"),"Global") set(#e05,$scrape attribute($element child($element offset(<tagname="p">,0)),"name"),"Global") add list to list(%e06,$scrape attribute($element child($element offset(<tagname="p">,0)),"name"),"Delete","Global") add list to list(%e07,$scrape attribute($element sibling(<name="p1h1">),"name"),"Delete","Global") set(#e08,$scrape attribute($element sibling($element offset(<tagname="p">,0)),"name"),"Global") add list to list(%e09,$scrape attribute($element sibling($element offset(<tagname="p">,0)),"name"),"Delete","Global") divider e01: h1 (OK) e02: returns: <nothing> expecting: [p1d1Subp1,p1d1Subp2,p1d1Subp3] e03: returns: <nothing> expecting: p1 e04: P1H1 (OK) e05: returns: <nothing> expecting: [p1h1,p1h2,p1h3,p1d1,p1d2] e06: (same as above except that the call returns to a list) returns: <nothing> expecting: [p1h1,p1h2,p1h3,p1d1,p1d2] e07: returns: <nothing> expecting: [p1h2,p1h3,p1d1,p1d2] (or at least p1h2) e08: returns: p1h1 (this is the child) expecting: p2 e09: returns: [p1h1] expecting: p2 (or from the results of e08 above, at least [p1h1,p1h2,p1h3,p1d1,p1d2] ) Quote Link to post Share on other sites
botsimmer 16 Posted February 18, 2015 Report Share Posted February 18, 2015 Hi there,Ubotbuddy has some valuable training on Parent / Child / Siblings that you may find useful. http://www.ubotstudio.com/forum/index.php?/topic/11724-training-learn-ubot-in-30-days-video-series/ Thanks Quote Link to post Share on other sites
Siegfried88 3 Posted February 23, 2015 Author Report Share Posted February 23, 2015 Thanks botsimmer, Much appreciated. Unfortunately, money is tight right now and I noticed that the most important tutorials are only paid. I'll have to find another solution. Also, I am concerned that the attributes may still have some problems when it comes to programming, specifically from looking at this thread... http://www.ubotstudio.com/forum/index.php?/topic/14290-parent-child-and-sibling-learninghelping-search-bot/ Although this was back in 2013, I thought things may have changed. 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.