flexfanatic 0 Posted September 15, 2013 Report Share Posted September 15, 2013 (edited) So after viewing a pretty good video tutorial on how to scrape data from a website I created my own bot for fun and it currently runs pretty good. Now I'm trying to change some of the UI elements (in this case the drop) to look better than what i currently have. The drop down is basically a selection of urls to choose from but I would like it to show up as the actually category (Art, Food, etc) instead of the full url path. http://s11.postimg.org/oasn074r7/uibox.png ui drop down("Category", "http://fancy.com/shop/art,http://fancy.com/shop/food", #categories)ui stat monitor("Titles Scraped:", $list total(%titles))ui stat monitor("URLs Scraped:", $list total(%urlslist))ui stat monitor("Images Scraped:", $list total(%fullsizeimage))ui stat monitor("Thumbnails Scraped:", $list total(%imageurls))define Scrape Data { clear cookies navigate(#categories, "Wait") clear table(&fancyitems) clear list(%titles) clear list(%urlslist) clear list(%fullsizeimage) clear list(%imageurls) clear list(%description) add list to list(%titles, $page scrape("<figcaption>", "</figcaption>"), "Don\'t Delete", "Global") add list to list(%urlslist, $page scrape("<a href=\"/things", "\""), "Don\'t Delete", "Global") remove from list(%urlslist, 0) add list to list(%imageurls, $page scrape("image:url(\'", "\')\">"), "Don\'t Delete", "Global") loop($list total(%imageurls)) { navigate("http://fancy.com/things{$next list item(%urlslist)}", "Wait") add item to list(%fullsizeimage, $scrape attribute(, "src"), "Don\'t Delete", "Global") add item to list(%description, $page scrape("<meta property=\"og:description\" content=\"", "\">"), "Delete", "Global") }}Scrape Data()add list to table as column(&fancyitems, 0, 0, %titles)add list to table as column(&fancyitems, 0, 1, %urlslist)add list to table as column(&fancyitems, 0, 2, %description)add list to table as column(&fancyitems, 0, 3, %fullsizeimage)save to file("{$special folder("Desktop")}/fancyitems.csv", &fancyitems)navigate("http://www.fancy.com/", "Wait")alert("I\'m Done. Wanna Play.") Edited September 15, 2013 by flexfanatic Quote Link to post Share on other sites
UBotDev 276 Posted September 15, 2013 Report Share Posted September 15, 2013 You can't do that with "ui drop down", you would need to use custom HTML UI and display it via "ui html panel". Here is an example: ui html panel("<select variable=\"#var\" fillwith=\"value\"> <option value=\"\">Select One</option> <option value=\"url1\">Cat1 </option> <option value=\"url2\">Cat2</option> <option value=\"url3\">Cat3</option> </select> ", 200) Quote Link to post Share on other sites
Edward_2 85 Posted September 15, 2013 Report Share Posted September 15, 2013 I think you need to scrape the caegory name as well as the URL. Make a list with the the cat names in it. Quote Link to post Share on other sites
flexfanatic 0 Posted September 16, 2013 Author Report Share Posted September 16, 2013 You can't do that with "ui drop down", you would need to use custom HTML UI and display it via "ui html panel". Here is an example: ui html panel("<select variable=\"#var\" fillwith=\"value\" /> <option value=\"\">Select One</option> <option value=\"url1\">Cat1 </option> <option value=\"url2\">Cat2</option> <option value=\"url3\">Cat3</option> </select> ", 200) Thanks that worked (although it broke my stat monitors but I can likely fix that without a lot of work). <select variable="#categories" fillwith="value" /><option value="">Select Category</option><option value="http://fancy.com/shop/art/">Art </option><option value="http://fancy.com/shop/food/">Food</option><option value="url3">Cat3</option></select> Quote Link to post Share on other sites
UBotDev 276 Posted September 16, 2013 Report Share Posted September 16, 2013 No problem. I actually noticed that I had a typo in my code, so I changed previous post... You will have to re-code the whole UI with HTML, since if you use "ui hml panel" that will prevent you to use other "ui" commands. In case you don't know, this is how ui stat looks like in HTML: <div variable="#STATUS" fillwith="innerhtml">Status</div> Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted September 16, 2013 Report Share Posted September 16, 2013 Here is another option for you... ui drop down("Choose Category", "None,Food, Art", #cats) if($comparison(#cats, "=", "Food")) { then { navigate("http://fancy.com/shop/food", "Wait") } } if($comparison(#cats, "=", "Art")) { then { navigate("http://fancy.com/shop/art", "Wait") } } 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.