Jump to content
UBot Underground

String Cannot Be Of Zero Length.......wtf?


Recommended Posts

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!

 

 

post-18544-0-97593100-1421319315_thumb.jpg

Link to post
Share on other sites

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!

Link to post
Share on other sites

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!!!")

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...