Thread Spawn
(→Example 2: Thread Spawn With Tables) |
|||
Line 64: | Line 64: | ||
− | [[File: | + | [[File:threadspawntable0.jpg]] |
Revision as of 22:01, 6 November 2015
The Thread Spawn command should NOT be used with the thread command.
This function is an Advanced Threading function in the UBot Extended Library. This command will spawn the specified number of threads, with the 'max concurrent' number of threads open at any given time.
Total Number of Threads: The number of threads being open.
Max Concurrent: The number of threads that should be open at a time.
Example 1: Thread Spawn With Lists
add list to list(%Plant Tree Research,$list from text("Honeysuckle, Nasturtium, Thorn Flower, Honey Locust, Bougainvillea",","),"Delete","Global") set list position(%Plant Tree Research,0) thread spawn(5,5) { in new browser { navigate("google.com","Wait") wait(3) type text(<name="q">,$next list item(%Plant Tree Research),"Standard") wait(6) } }
A list is created to provide list items to each thread created by the command. Inside the thread command is an In New Browser, which will open a new browser instance for each thread.
For each thread, a new window will open, and the search field will be filled with an item from the list.
Example 2: Thread Spawn With Tables
The example below will fill the fields on the sample web page with each item in the table.
Notice that a type text command with a table cell function is available for each item in the column Notice that the row is set to a variable being incremented by the thread spawn command.
navigate("http://www.w3schools.com/html/html_tables.asp","Wait") wait(2) scrape table(<innertext="First Name">,&my table) set(#row,0,"Global") thread spawn($table total rows(&my table),2) { in new browser { navigate("http://www.ubotstudio.com/playground/simple-form","Wait") wait(2) type text(<username field>,$table cell(&my table,#row,0),"Standard") type text(<first name field>,$table cell(&my table,#row,1),"Standard") type text(<last name field>,$table cell(&my table,#row,2),"Standard") type text(<about me textarea>,$table cell(&my table,#row,3),"Standard") increment(#row) wait(8) } }
Running the script increments through each table item and fills each field on each web page with the contents of the table.