ATuringtest 14 Posted December 5, 2019 Report Share Posted December 5, 2019 How to select this element ? I want to select the element and click it, its always the last element before the "Next" element. The position/element number changes depending on the amount of pages but is always before the "Next" button. So if its 32 pages it would be |32|Next.> Quote Link to post Share on other sites
HelloInsomnia 1103 Posted December 5, 2019 Report Share Posted December 5, 2019 There are various ways to do this; I can explain one way - but its always best if you are able to include the website along with any code you have if you want somebody to be able to help. What you can do is scrape the elements into a list and use the offset of the second to last element. e.g. if there are 7 elements the list total is 7 and the offset for the second to last would be 5 (because offset starts at 0) Quote Link to post Share on other sites
ATuringtest 14 Posted December 5, 2019 Author Report Share Posted December 5, 2019 There are various ways to do this; I can explain one way - but its always best if you are able to include the website along with any code you have if you want somebody to be able to help. What you can do is scrape the elements into a list and use the offset of the second to last element. e.g. if there are 7 elements the list total is 7 and the offset for the second to last would be 5 (because offset starts at 0) Ill give that a go an post the results thanks for that Quote Link to post Share on other sites
ATuringtest 14 Posted December 9, 2019 Author Report Share Posted December 9, 2019 Any help would be much appreciatedAnd I'm totally new to Ubot so I would grateful if you explain methods in as simple turns as possible So I'm trying to select class="">2</a> to class="">10</a> add it to a list and then as you said offset it. Or run a largest number returned click element.I can scrape the inner text and it returns the value of 2 for element with the number 2 in it. But if I select tag name it returns 460 so that's no good.Basically I'm trying to navigate to the last page then post of a forum post on BHW https://www.blackhatworld.com/seo/mass-parasite-backlinks-only-10-per-1000-link-in-post-25-per-1000-very-low-cost.1123322/ So this is my sudo code Navigate to urlLook for Name Text BoxEnter nameEnter PasswordPress login buttonScrape Element X (Page-(number(s))Add (Page-(number) to list YRead ListSelect highest (Page-(number) elementClick Once I have this done I'll move on to finding the last post. -------------------------- webpage code --------------------------------------- <div class="PageNav" data-page="1" data-range="2" data-start="2" data-end="6" data-last="10" data-sentinel="{{sentinel}}" data-baseurl="blahblahblah.1123322/page-{{sentinel}}"><span class="pageNavHeader">Page 1 of 10</span><nav><a href="blahblahblah.1123322/" class="currentPage " rel="start">1</a><a class="PageNavPrev hidden" style="">←</a> <span class="scrollable"><span class="items"><a href="blahblahblah.1123322/page-2" class="">2</a><a href="blahblahblah.1123322/page-3" class="">3</a><a href="blahblahblah.1123322/page-4" class="">4</a><a href="blahblahblah.1123322/page-5" class="">5</a><a href="blahblahblah.1123322/page-6" class="">6</a></span></span> <a class="PageNavNext " style="">→</a><a href="blahblahblah.1123322/page-10" class="">10</a><a href="blahblahblah.1123322/page-2" class="text">Next ></a></nav></div> Quote Link to post Share on other sites
ATuringtest 14 Posted December 9, 2019 Author Report Share Posted December 9, 2019 (edited) So Ive managed to get to this point %pages:blhablahblahblah.1123322/page-2blhablahblahblah.1123322/page-3blhablahblahblah.1123322/page-4blhablahblahblah.1123322/page-5blhablahblahblah.1123322/page-6blhablahblahblah.1123322/page-10 Which is a start lol ! Edited December 9, 2019 by ATuringtest Quote Link to post Share on other sites
ATuringtest 14 Posted December 9, 2019 Author Report Share Posted December 9, 2019 Ok I now have the element I want to click in a variable - how do I click on element using the stored variable ? Quote Link to post Share on other sites
ATuringtest 14 Posted December 9, 2019 Author Report Share Posted December 9, 2019 (edited) Ok so I did Navigate | www.domain/%variable and that seem to work ... lolif theres a neater way of ding it plz let me know Edited December 9, 2019 by ATuringtest Quote Link to post Share on other sites
UBotBuddy 331 Posted December 10, 2019 Report Share Posted December 10, 2019 @ATuringtest Give this a try! loop(1) { set(#var,$scrape attribute($element offset(,0),"outerhtml"),"Global") set(#var2,$find regular expression(#var,"href=\"(.*?)\""),"Global") clear list(%targetURL) add list to list(%targetURL,$list from text(#var2,""),"Delete","Global") loop(6) { remove from list(%targetURL,0) } set(#var,"","Global") set(#var2,"","Global")} I tested this on several pages from that forum and it is pretty quick and efficient. Buddy 1 Quote Link to post Share on other sites
ATuringtest 14 Posted December 10, 2019 Author Report Share Posted December 10, 2019 (edited) @ATuringtest Give this a try! loop(1) { set(#var,$scrape attribute($element offset(<class="PageNav">,0),"outerhtml"),"Global") set(#var2,$find regular expression(#var,"href=\"(.*?)\""),"Global") clear list(%targetURL) add list to list(%targetURL,$list from text(#var2,""),"Delete","Global") loop(6) { remove from list(%targetURL,0) } set(#var,"","Global") set(#var2,"","Global")} I tested this on several pages from that forum and it is pretty quick and efficient. Buddy Thanks @Ubotbuddy I'll give this a go as well This is what I shrunk the code down to set(#pages,$scrape attribute($element offset(<href=w"*/page-*">,6),"href"),"Global") Theres no need for a list, the on page html ahref elements is the same no matter how many pages a thread has. Edited December 10, 2019 by ATuringtest 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.