itexspert 47 Posted January 15, 2015 Report Share Posted January 15, 2015 Guys i have strange thing i am trying to scrape Phone number from this spanish site and my goal is this i have to scrape only mobile numbers so every number which starts with "9" will be excluded from Scraping results and i managed to do the hard part but i have this weird issue.Check the Image Attached on load("Bot Loaded") { navigate("http://www.milanuncios.com/ofertas-de-empleo/","Wait")}wait for browser event("Everything Loaded","")wait for browser event("DOM Ready","")set(#loop,0,"Global")loop(#loop) { click($element offset(<tagname="b">,#loop),"Left Click","No") set(#number,$scrape attribute(<class="telefonos">,"innertext"),"Global") set(#number,$replace(#number,$find regular expression(#number,"[^\\d]([\{6,7\}][\\d\\s]\{7,10\})[^\\d]"),$nothing),"Global") save to file("{$special folder("Desktop")}\\scraped phones.csv",#number)} I tested the Regex and it works but for some reason Ubot registered an error must have made one i just don't know where it is! Any help is greatly appreciated! Quote Link to post Share on other sites
arunner26 51 Posted January 15, 2015 Report Share Posted January 15, 2015 itexspert,The code below tells UBOT you want to loop zero times. set(#loop,0,"Global")loop(#loop) { Quote Link to post Share on other sites
itexspert 47 Posted January 15, 2015 Author Report Share Posted January 15, 2015 Hahaa thanks man but that is really not an issue try to scrape something and then run node on Replace regex that is my issue i know about the loop man haha...you made me laugh! Anyway when i scrape number into variable then i try to replace the regular Expression and that is the source of my problem! EDIT: If it helps this is the corrected version of Loop on load("Bot Loaded") { navigate("http://www.milanuncios.com/ofertas-de-empleo/","Wait")}wait for browser event("Everything Loaded","")wait for browser event("DOM Ready","")set(#loop,30,"Global")loop(#loop) { click($element offset(<tagname="b">,#loop),"Left Click","No") set(#number,$scrape attribute(<class="telefonos">,"innertext"),"Global") set(#number,$replace(#number,$find regular expression(#number,"[^\\d]([\{6,7\}][\\d\\s]\{7,10\})[^\\d]"),$nothing),"Global") save to file("{$special folder("Desktop")}\\scraped phones.csv",#number)} But my issue is when i want to replace regex! Quote Link to post Share on other sites
arunner26 51 Posted January 15, 2015 Report Share Posted January 15, 2015 itexspert,Can't really try it because you don't show the full URL. navigate("http://www.milanunci...rtas-de-empleo/","Wait") Quote Link to post Share on other sites
itexspert 47 Posted January 15, 2015 Author Report Share Posted January 15, 2015 its http://www.milanuncios.com/ofertas-de-empleo/ Quote Link to post Share on other sites
arunner26 51 Posted January 15, 2015 Report Share Posted January 15, 2015 itexspert,Check out the script below as one solution to grab those phone numbers not starting with 9:Don't forget to change the URL below to the full URL (milanuncios.com/ofertas-de-empleo) ui stat monitor("Numbers To Save:", %numbers)navigate("http://www.milanuncios.com/ofertas-de-empleo/", "Wait")wait for browser event("Everything Loaded", "")wait for browser event("DOM Ready", "")set(#number, $nothing, "Global")set(#loop, 5, "Global")set(#loopindex, 0, "Global")clear list(%numbers)set(#ContinueLooking, 1, "Global")loop while($comparison(#ContinueLooking, "=", 1)) { click($element offset(<class="i5">, #loopindex), "Left Click", "No") wait for browser event("Everything Loaded", "") wait(2) set(#WindowOpen, $nothing, "Global") set(#WindowOpen, $scrape attribute(<class="cerrarw">, "outerhtml"), "Global") if($comparison(#WindowOpen, "=", $nothing)) { then { set(#ContinueLooking, 0, "Global") } else { } } set(#number, $nothing, "Global") set(#number, $scrape attribute($element offset(<class="telefonos">, 0), "innertext"), "Global") if($comparison(#number, "!=", $nothing)) { then { if($comparison($substring(#number, 0, 1), "!=", 9)) { then { add item to list(%numbers, #number, "Delete", "Global") } else { } } } else { } } set(#number, $nothing, "Global") set(#number, $scrape attribute($element offset(<class="telefonos">, 1), "innertext"), "Global") if($comparison(#number, "!=", $nothing)) { then { if($comparison($substring(#number, 0, 1), "!=", 9)) { then { add item to list(%numbers, #number, "Delete", "Global") } else { } } } else { } } click(<class="cerrarw">, "Left Click", "No") wait(1) set(#loopindex, $add(#loopindex, 1), "Global")}save to file("{$special folder("Desktop")}\\scraped phones.csv", %numbers)alert("Processing Complete!!!") Quote Link to post Share on other sites
itexspert 47 Posted January 15, 2015 Author Report Share Posted January 15, 2015 Thanks Man Will try! 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.