Jump to content
UBot Underground

How to use multi threading to login the same site?


Recommended Posts

I'm a new Ubot user and I found a post about multi Threading in Ubot.
http://www.ubotstudio.com/forum/index.php?/topic/10042-new-v4-tutorial-multi-threading-example/

I met a problem when using multi threading when login a website.
For example, when I use two threads to login a same website.
There are two windows to input username, password and then press login at the same time. but they always get the same account data because at that time the "account position" is the same.
How can I make the different thread use the different account data?
When a thread get the "account position" is 0, how to let another thread get the "account position" is 1 quickly?

Thank you for your help.

Here is my code:
==========================================================
ui open file("Accounts List(CSV):", #accounts list)
ui drop down("Thread", "1,2,3,4,5,6,7,8,9,10", #num threads)
set(#used threads, 0, "Global")
set(#account position, 0, "Global")
clear table(&account list)
create table from file(#accounts list, &account list)
loop($table total rows(&account list)) {
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    loop process()
}
define loop process {
    increment(#used threads)
    start up()
}
define start up {
    thread {
        in new browser {
            clear cookies
            Login Method()
            decrement(#used threads)
        }
    }
}
define Login Method {
    if($comparison($url, "!=",

 "https://www.tumblr.com/login")) {
        then {
            navigate("https://www.tumblr.com/login", "Wait")
        }
        else {
        }
    }
    wait for browser event("Everything Loaded", "")
    wait(10)
    type text(<email field>, $table cell(&account list, #account position, 0), "Standard")
    wait(1)
    type text(<password field>, $table cell(&account list, #account position, 1), "Standard")
    wait(2)
    click(<create account button>, "Left Click", "No")
    wait for browser event("Everything Loaded", "")
    wait(5)
    increment(#account position)
}
Edited by jythoner
Link to post
Share on other sites

I do the following. 
 
In the initial loop I put a a few second wait after loop process() so that the threads won't start at the same time. 
 
loop($table total rows(&account list)) {
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    loop process()
}
 
Afterwards, in the Login Method I would set a Local variable called "local account position" to the value of the "account position". Right afterwards, I would increment the "account position" variable. When typing the text instead of using "account position" use "local account position". The only problem is that in the debugger, local variables don't show and you might think its not working, but when you compile it will work.

 

Here is the new code.

ui open file("Accounts List(CSV):", #accounts list)
ui drop down("Thread", "1,2,3,4,5,6,7,8,9,10", #num threads)
set(#used threads, 0, "Global")
set(#account position, 0, "Global")
clear table(&account list)
create table from file(#accounts list, &account list)
loop($table total rows(&account list)) {
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    loop process()
    wait(5)
}
define loop process {
    increment(#used threads)
    start up()
}
define start up {
    thread {
        in new browser {
            clear cookies
            Login Method()
            decrement(#used threads)
        }
    }
}
define Login Method {
    set(#local account position, #account position, "Local")
    increment(#account position)
    wait(.1)
    if($comparison($url, "!=", "https://www.tumblr.com/login")) {
        then {
            navigate("https://www.tumblr.com/login", "Wait")
        }
        else {
        }
    }
    wait for browser event("Everything Loaded", "")
    wait(10)
    type text(<email field>, $table cell(&account list, #local account position, 0), "Standard")
    wait(1)
    type text(<password field>, $table cell(&account list, #local account position, 1), "Standard")
    wait(2)
    click(<create account button>, "Left Click", "No")
    wait for browser event("Everything Loaded", "")
    wait(5)
}
Link to post
Share on other sites

@the OP

replied to your email for you...

 

 

@ds062692

 

The problem with your setup is if a thread starts the same time as another the variable count could skip..

 

Better to do as follows

 

ui open file("Accounts List(CSV):", #accounts list)
ui drop down("Thread", "1,2,3,4,5,6,7,8,9,10", #num threads)
set(#used threads, 0, "Global")
set(#account position, 0, "Global")
clear list(%accounts)
add list to list(%accounts, $list from file(#accounts list), "Delete", "Global")
set list position(%accounts, 0)
loop($list total(%accounts)) {
    loop while($comparison(#used threads, ">=", #num threads)) {
        wait(1)
    }
    loop process()
}
define loop process {
    increment(#used threads)
    start up()
}
define start up {
    thread {
        in new browser {
            clear cookies
            Login Method()
            decrement(#used threads)
        }
    }
}
define Login Method {
    if($comparison($add($list position(%accounts), 1), ">", $list total(%accounts))) {
        then {
        }
        else {
            if($comparison($url, "!=", "https://www.tumblr.com/login")) {
                then {
                    navigate("https://www.tumblr.com/login", "Wait")
                }
                else {
                }
            }
            wait for browser event("Everything Loaded", "")
            wait(10)
            add list to list(%local details, $list from text($next list item(%accounts), ","), "Delete", "Local")
            type text(<email field>, $list item(%local details, 0), "Standard")
            wait(1)
            type text(<password field>, $list item(%local details, 1), "Standard")
            wait(2)
            click(<create account button>, "Left Click", "No")
            wait for browser event("Everything Loaded", "")
            wait(5)
        }
    }
}
 

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