Jump to content
UBot Underground

Recommended Posts

Hi guys, so the multithreading works with my code below but only if the "sexProxy" define is removed from inside "thread code". How can I make it work with proxy? Any suggestions?

 

 

define setProxy(#fnProxyWithCredentials) {
    set(#fnProxyWithCredentials#fnProxyWithCredentials"Global")
    clear list(%fnProxy)
    add list to list(%fnProxy$list from text(#fnProxyWithCredentials":"), "Delete""Global")
    set(#fnProxyUsername$list item(%fnProxy, 2), "Global")
    set(#fnProxyPassword$list item(%fnProxy, 3), "Global")
    set(#fnProxyWithPort"{$list item(%fnProxy, 0)}:{$list item(%fnProxy, 1)}""Global")
    set proxy credentials(#fnProxyUsername#fnProxyPassword)
    change proxy(#fnProxyWithPort)
    wait(3)
}
ui open file("Proxy"#proxy list)
clear list(%proxy list)
add list to list(%proxy list$list from file(#proxy list), "Delete""Global")
clear list(%url list)
add item to list(%url list"www.google.com""Delete""Global")
add item to list(%url list"www.bing.com""Delete""Global")
add item to list(%url list"http://clusty.com/""Delete""Global")
add item to list(%url list"http://www.dogpile.com/""Delete""Global")
ui drop down("Thread Count""2,3,4,5,6,7,8,9,10"#num threads)
set(#used threads, 0, "Global")
set(#url list index, 0, "Global")
set(#total urls$list total(%url list), "Global")
loop(#total urls) {
    loop while($comparison(#used threads">="#num threads)) {
        wait(1)
    }
    increment(#used threads)
    thread {
        in new browser {
            if($comparison(#url list index"<"#total urls)) {
                then {
                    comment("PLACE YOUR CODE TO ME MULTI THREADED HERE")
                    thread code(#url list index)
                }
                else {
                }
            }
            decrement(#used threads)
        }
    }
    wait(1)
    increment(#url list index)
}
define thread code(#thread url list index) {
    set(#index#thread url list index"Global")
    set(#current proxy$random list item(%proxy list), "Global")
    comment("Multithread works when I remove setProxy below")
    setProxy(#current proxy)
    navigate($list item(%url list#index), "Wait")
    wait for browser event("Everything Loaded""")
    wait(10)
}

 

 

Link to post
Share on other sites

You need to have an additional define command around thread.

 

I think thats the problem, and variable #url list index,is getting constantly changed (even when it shouldn't, inside running thread).

  • Like 1
Link to post
Share on other sites

You need to have an additional define command around thread.

 

I think thats the problem, and variable #url list index,is getting constantly changed (even when it shouldn't, inside running thread).

 

I followed LoWrIdErTJ's multi threading example except that I removed the defines. Is it really necessary for multi threading to work to put the commands in different defines?

 

Also, I don't think there's a problem with #url list index because the whole code works. It only stops working when I added the proxy inside the thread. Try removing the  setProxy(#current proxy) command from inside the thread code and you'll see that it works. 

Edited by esthonwood
Link to post
Share on other sites

You need define around thread if you are passing any parameters inside threads, so that parameters don't change while thread is running. In your case variable " #url list index" is set globally, which means it gets changed all the times, even when it shouldn't...when thread is running and it expects constant value. I haven't reviewed TJ's threading, but this here doesn't look good at all.

 

Besides that, I've noticed you are using Global variables int thread, which means they all write into one variable...instead you should use local variables, so each thread has it's own version of variable.

  • Like 2
Link to post
Share on other sites

You need define around thread if you are passing any parameters inside threads, so that parameters don't change while thread is running. In your case variable " #url list index" is set globally, which means it gets changed all the times, even when it shouldn't...when thread is running and it expects constant value. I haven't reviewed TJ's threading, but this here doesn't look good at all.

 

Besides that, I've noticed you are using Global variables int thread, which means they all write into one variable...instead you should use local variables, so each thread has it's own version of variable.

 

Ok, I think I understand it now. I will let you know how this turns out. Thanks so much for your help :)

Link to post
Share on other sites

Ok, so I've made some changes on my code and I've set all the variables inside the thread to be local. It still doesn't work. I apologize for bugging you guys, but I've been at this for days and I can't make the proxy to work inside the thread :( Any ideas?

 

comment("Proxy is in this format: IP:PORT:USERNAME:PASSWORD")
ui open file("Proxy"#proxy list)
clear list(%proxy list)
add list to list(%proxy list$list from file(#proxy list), "Delete""Global")
clear list(%url list)
add item to list(%url list"www.google.com""Delete""Global")
add item to list(%url list"www.bing.com""Delete""Global")
add item to list(%url list"http://clusty.com/""Delete""Global")
add item to list(%url list"http://www.dogpile.com/""Delete""Global")
ui drop down("Thread Count""2,3,4,5,6,7,8,9,10"#num threads)
set(#used threads, 0, "Global")
set(#url list index, 0, "Global")
set(#total urls$list total(%url list), "Global")
loop(#total urls) {
    loop while($comparison(#used threads">="#num threads)) {
        wait(1)
    }
    increment(#used threads)
    set(#current proxy$random list item(%proxy list), "Global")
    thread {
        in new browser {
            if($comparison(#url list index"<"#total urls)) {
                then {
                    comment("PLACE YOUR CODE TO ME MULTI THREADED HERE")
                    thread code(#url list index#current proxy)
                }
                else {
                }
            }
            decrement(#used threads)
        }
    }
    wait(1)
    increment(#url list index)
}
define thread code(#thread url list index#thread current proxy) {
    clear list(%fnProxy)
    add list to list(%fnProxy$list from text(#thread current proxy":"), "Delete""Local")
    set(#fnProxyUsername$list item(%fnProxy, 2), "Local")
    set(#fnProxyPassword$list item(%fnProxy, 3), "Local")
    set(#fnProxyWithPort"{$list item(%fnProxy, 0)}:{$list item(%fnProxy, 1)}""Local")
    set proxy credentials(#fnProxyUsername#fnProxyPassword)
    change proxy(#fnProxyWithPort)
    wait(3)
    navigate($list item(%url list#thread url list index), "Wait")
    wait for browser event("Everything Loaded""")
    wait(10)
}

Link to post
Share on other sites

If your proxy username will be the same as password, you need to change line bellow (else password used would be blank ""):

:

 add list to list(%fnProxy, $list from text(#thread current proxy, ":"), "Delete", "Local")

...since you don't want to delete duplicates in that case.

Link to post
Share on other sites

If your proxy username will be the same as password, you need to change line bellow (else password used would be blank ""):

:

 add list to list(%fnProxy, $list from text(#thread current proxy, ":"), "Delete", "Local")

...since you don't want to delete duplicates in that case.

 

the proxy name is not the same as the password.

Link to post
Share on other sites

 

Hi Traffik Cop, I've adopted the code from your proxy checker above. Any ideas why, when I add the proxy, the bot won't work? I'm sorry for continuously bugging you guys, but I just can't seem to make the proxy work in a multi-thread :( Any help is greatly appreciated.

 

ui open file("Proxy file"#proxy file)

ui drop down("How many threads?""2,3,4,5"#num threads)

define createLists {

    clear list(%proxy list nest item)

    clear list(%url list)

    add item to list(%url list"www.google.com""Delete""Global")

    add item to list(%url list"www.bing.com""Delete""Global")

    add item to list(%url list"www.clusty.com""Delete""Global")

    add item to list(%url list"www.dogpile.com""Delete""Global")

    set list position(%url list, 0)

    clear list(%proxy list)

    add list to list(%proxy list$list from file(#proxy file), "Delete""Global")

    set list position(%proxy list, 0)

}

createLists()

set(#used threads, 0, "Global")

set(#completed rows, 0, "Global")

loop($list total(%url list)) {

    loop while($comparison(#used threads">="#num threads)) {

        wait(1)

    }

    loop process()

}

define loop process {

    increment(#used threads)

    run procedure()

}

define run procedure {

    thread {

        in new browser {

            code procedure()

            decrement(#used threads)

        }

    }

}

define code procedure {

    if($comparison(#completed rows"<"$list total(%url list))) {

        then {

            add list to list(%proxy list nest item$list from text($random list item(%proxy list), ":"), "Don\'t Delete""Local")

            set(#poroxy$list item(%proxy list nest item, 0), "Local")

            set(#poroxy port$list item(%proxy list nest item, 1), "Local")

            set(#user name$list item(%proxy list nest item, 2), "Local")

            set(#password$list item(%proxy list nest item, 3), "Local")

            set proxy credentials(#user name#password)

            clear cookies

            wait(1)

            change proxy("{#poroxy}:{#poroxy port}")

            set(#current url$next list item(%url list), "Local")

            navigate(#current url"Wait")

            wait for browser event("Everything Loaded""")

            wait(10)

        }

        else {

        }

    }

    increment(#completed rows)

}

Link to post
Share on other sites

What's exactly wrong with it? It works fine for me.

 

What are you trying to do?

 

Are you trying to check each proxy against each site? then yeah it's wrong. you will need another loop inside the thread.

 

Maybe your proxies are bad?

 

I would say proxies are bad cuz I used your code exactly and it worked fine with my private proxies!

Link to post
Share on other sites

What's exactly wrong with it? It works fine for me.

 

What are you trying to do?

 

Are you trying to check each proxy against each site? then yeah it's wrong. you will need another loop inside the thread.

 

Maybe your proxies are bad?

 

I would say proxies are bad cuz I used your code exactly and it worked fine with my private proxies!

 

Hi TC, what I'm trying to do is open each URL (from the %url list) inside a thread. When you say it works fine for you, do you mean that the proxy is successfully changed and the URLs are loaded fully?

 

You see, in my case, it would open the URL inside a thread and the browser address bar would indicate that it's loading the URL but the browser just shows a blank white page.

Edited by esthonwood
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...