Jump to content
UBot Underground

looping help


Recommended Posts

Hi all,

so I'm having trouble, and I think it's with looping

What I want to happen is to have the bot rotate thru the alphabet and scrape results BUT the bot needs to cycle thru the javascript code to go to the bottom of the page until the bottom of the page is reached for each letter.  I want to add the data scraped from each letter to a total list.

Here's what I have, I think I'm screwing up the looping somewhere...  Thanks for any help!

 

 

ui text box("Facebook Email", #FBemail)
ui text box("Facebook Password", #FBpassword)
ui text box("Last Name", #LastName)
navigate("http://www.facebook.com", "Wait")
type text($element offset(<email field>, 0), #FBemail, "Standard")
clear list(%Alphabet)
add list to list(%Alphabet, $list from file("C:\\Users\\Administrator\\Desktop\\Alphabet.txt"), "Delete", "Global")
set(#Alphabetposition, $list item(%Alphabet, 0), "Global")
type text($element offset(<password field>, 0), #FBpassword, "Standard")
click(<login button>, "Left Click", "No")
wait for browser event("Everything Loaded", "")
navigate("www.facebook.com/friends/requests", "Wait")
clear list(%TotalLastName)
loop(1) {
    loop(1) {
        clear list(%LastNames)
        type text(<name="name_input">, "{#Alphabetposition} {#LastName}", "Standard")
        click(<id="u_0_x">, "Left Click", "No")
        wait for browser event("Everything Loaded", "")
        add list to list(%LastNames, $scrape attribute(<href=w"https://www.facebook.com/*?">, "href"), "Delete", "Global")
        set(#Loop, 0, "Global")
        loop while($comparison(#Loop, "!=", $list total(%LastNames))) {
            run javascript("window.scrollTo(0,document.body.scrollHeight)")
            wait(2)
            set(#Loop, $list total(%LastNames), "Global")
            wait for browser event("Everything Loaded", "")
            add list to list(%LastNames, $scrape attribute(<href=w"https://www.facebook.com/*?">, "href"), "Delete", "Global")
            if($comparison(#Loop, "=", %LastNames)) {
                then {
                    increment(#Alphabetposition)
                }
                else {
                }
            }
        }
        add list to list(%TotalLastName, %LastNames, "Delete", "Global")
    }
}
 

Link to post
Share on other sites

thanks for the suggestion Ubotdev but that's not working... it's not looping all the way thru, and not scrolling.

Aa I said, you'll be safer by adding "wait for element" command, it might be the reason for some of your problems.

 

I also noticed that you have an error on this line "if($comparison(#Loop, "=", %LastNames)) {" ....I think you are trying to compare #Loop to list size, that's why you should use $list total(%LastNames).

 

Oh, and sometimes scrolling to the bottom only won't work, you'll also have to click "load more" button.

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