Jump to content
UBot Underground

Ui Dropdown Auto Generated From A Scrape Of A Dropdown


Recommended Posts

Hi,

I'm trying to populate a ui drop down from a scrape of a dropdown and would appreciate any guidance / help.

 

Here is what I have so far... 

 


wait(5)

set(#var02,$scrape attribute(<id=w"reportMonthSelector_chzn_o_*">,"innertext"),"Global")

ui drop down("Select Start date",#var02,#var02)

 

I'd like the list of dates to populate the ui dropdown, but as you as see it ends up being one drop down option that includes the list of all of the dates in one row.

 

Any help/input/guidance on a fix would be appreciated.   Please note that the next step in my process will be to have my scraper select each of the previous 12 months, one-by-one,  and then scrape some specific data from each result (in case that affects your guidance/help).

 

Thanks in advance for any help offered.

Chris

Edited by christojuan
Link to post
Share on other sites

Hi,

 

Here are two options using the file management plugin

 

Just put your scrape attribute instead of my fake data.

comment("most likely the data will look like a list
on seperate lines")
set(#scraped data,"one
two
three","Global")
comment("$text from list 
just joins the list with a coma")
set(#list box,$plugin function("File Management.dll", "$listbox dialog", "Choose an item!", "Choose", $text from list($list from text(#scraped data,$new line),",")),"Global")
set(#drop down,$plugin function("File Management.dll", "$dropdown dialog", "Choose item...", "Choose:", $text from list($list from text(#scraped data,$new line),",")),"Global")

Regards,
Nick

file management dd an list box - example.ubot

Link to post
Share on other sites

Hey - Thanks very much for your help Nick. While I was not able to download the file management plugin (the site is down and amazon permissions are not allowing downloads). I used an idea from something I saw in your code to do the following and it worked great!

 

navigate("http://bazoogle3.com/testscrape/","Wait")
set(#var1,$scrape attribute(<id=w"reportMonthSelector_chzn_o_*">,"innertext"),"Global")
add list to list(%list1,$list from text(#var1,"
"),"Delete","Global")
ui drop down("Select",$text from list(%list1,","),#var2)

 

Thanks again!

  • Like 1
Link to post
Share on other sites

Quick follow up to that.  When I run the script the first time, the drop down does not populate, but when I run it a second time it does.

Does anyone have any insights on why that happens and how I might be able to fix?

Thanks!
Chris

Link to post
Share on other sites

Quick follow up to that.  When I run the script the first time, the drop down does not populate, but when I run it a second time it does.

Does anyone have any insights on why that happens and how I might be able to fix?

Thanks!

Chris

 

UI refresh problem I think, if you click to code view and back after the first time does it populate? Or add a new tab and come back. I don't know if there's a solution to that I think somebody has a plugin but maybe there is some other way to do it. I use HTML or XAML GUI to get around this kind of thing.

Link to post
Share on other sites

That was it regarding he refresh! :)  And Aymen sent me a direct link to the free plugins so I have those now (still my solution works ok for now).

Thanks Nick and NIck!

Edited by christojuan
Link to post
Share on other sites

Hey,

Quick follow-up to Nick's code sample. When I finally got Aymen's plugin, I realized how cool this is but... I'm struggling with how to execute the code.

 

I'm probably missing something very obvious, but how can I have the selected dropdown item become the first drop-down selection where those dates previous to the selected dropdown would not be executed.  In other words the first scraped page should be the result of the selected drop down (e.g. 03/2016) and all subsequent should be 02/2016 then 01/2016 and then 12/2015 to the end excluding all dates prior to the 03/2016)

 

(Note that this code will generate 92 over and over. That's OK. on the live intranet site, it will page through the dates properly.)

 

navigate("http://bazoogle3.com/testscrape/","Wait")
clear list(%dates)
add list to list(%dates,$list from text($scrape attribute(<id=w"reportMonthSelector_chzn_o_*">,"innertext"),$new line),"Delete","Global")
set(#drop down,$plugin function("File Management.dll", "$dropdown dialog", "Choose item...", "Choose:", $text from list(%dates,",")),"Global")
loop($list total(%dates)) {
    set(#date NLI,$next list item(%dates),"Global")
    wait(3)
    change dropdown(<value=w"*">,#date NLI)
    set(#var3,$scrape attribute($element offset(<class="stat">,0),"innertext"),"Global")
    set(#var4,$replace(#var3," CONTACTS",$nothing),"Global")
    add item to list(%list2,#var4,"Don\'t Delete","Global")
}

 

Any additional help would be appreciated.

Thanks!
Chris

Link to post
Share on other sites

You will have to test this of course but this should check for the date selected then start adding that date and those after to a new list which then gets used instead:

navigate("http://bazoogle3.com/testscrape/","Wait")
clear list(%dates)
add list to list(%dates,$list from text($scrape attribute(<id=w"reportMonthSelector_chzn_o_*">,"innertext"),$new line),"Delete","Global")
set(#drop down,$plugin function("File Management.dll", "$dropdown dialog", "Choose item...", "Choose:", $text from list(%dates,",")),"Global")
clear list(%useableDates)
set(#dateFound,"false","Global")
loop($list total(%dates)) {
    set(#curDate,$next list item(%useableDates),"Global")
    if($comparison(#drop down,"= Equals",#curDate)) {
        then {
            set(#dateFound,"true","Global")
        }
        else {
        }
    }
    if($comparison(#dateFound,"=","true")) {
        then {
            add item to list(%useableDates,#curDate,"Don\'t Delete","Global")
        }
        else {
        }
    }
}
loop($list total(%useableDates)) {
    set(#date NLI,$next list item(%useableDates),"Global")
    wait(3)
    change dropdown(<value=w"*">,#date NLI)
    set(#var3,$scrape attribute($element offset(<class="stat">,0),"innertext"),"Global")
    set(#var4,$replace(#var3," CONTACTS",$nothing),"Global")
    add item to list(%list2,#var4,"Don\'t Delete","Global")
}
Link to post
Share on other sites

Whoops accidentally switched something around, try this:

navigate("http://bazoogle3.com/testscrape/","Wait")
clear list(%dates)
add list to list(%dates,$list from text($scrape attribute(<id=w"reportMonthSelector_chzn_o_*">,"innertext"),$new line),"Delete","Global")
set(#drop down,$plugin function("File Management.dll", "$dropdown dialog", "Choose item...", "Choose:", $text from list(%dates,",")),"Global")
clear list(%useableDates)
set(#dateFound,"false","Global")
loop($list total(%dates)) {
    set(#curDate,$next list item(%dates),"Global")
    if($comparison(#drop down,"= Equals",#curDate)) {
        then {
            set(#dateFound,"true","Global")
        }
        else {
        }
    }
    if($comparison(#dateFound,"=","true")) {
        then {
            add item to list(%useableDates,#curDate,"Don\'t Delete","Global")
        }
        else {
        }
    }
}
loop($list total(%useableDates)) {
    set(#date NLI,$next list item(%useableDates),"Global")
    wait(3)
    change dropdown(<value=w"*">,#date NLI)
    set(#var3,$scrape attribute($element offset(<class="stat">,0),"innertext"),"Global")
    set(#var4,$replace(#var3," CONTACTS",$nothing),"Global")
    add item to list(%list2,#var4,"Don\'t Delete","Global")
}
Link to post
Share on other sites

Absolutely perfect!  I'll tell you what, it's the selfless help from people like you, and Nick (Code Docta), Dan (bot-factory), Buddy S., Aymen, Deliter, and Valo (and that's just in the few weeks that I have been posting) that has made this work. This is why ubot will work for me and I will continue to subscribe. I love the learning and very much appreciate the help.

  • Like 2
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...