<?php
// The following code is required to properly run Xedant.com Human Emulator
require("../Templates/xweb_human_emulator.php");
// function for generation accept string
function generate_accept($len)
{
$r = "";
$allowedSymbols = array("text/html", "image/png", "image/jpeg", "image/gif", "image/x-xbitmap","text/plain", "q=0.5", "text/html", "text/x-dvi", "q=0.8", "text/x-c","audio/*","q=0.2", "audio/basic","image/gif", "image/x-xbitmap", "image/jpeg", "image/pjpeg", "application/x-shockwave-flash", "application/vnd.ms-excel", "application/vnd.ms-powerpoint", "application/msword","*/*");
for ($i=0; $i<$len; $i++)
{
$rand=array_rand($allowedSymbols);
$rand=array_rand($allowedSymbols);
$r.=$allowedSymbols[$rand].",";
}
$r = substr($r,0,strlen($r)-1);
$r="Accept: ".$r.";";
return $r;
}
// aply browser data
$browser->set_accept(generate_accept(rand(1,7)));
$browser->set_accept_encoding("gzip, deflate");
$browser->set_user_agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)");
// clear cash
$browser->clear_cash();
// navigate to ip pages for check browser data. see field Accept:
$browser->navigate("http://www.ippages.com/?version=full");
// wait on browser
$browser->wait_for(60,1);
// Quit
$app->quit();
?>
Web Human Emulator scripts
Blog about the Web Human Emulator. Web Human Emulator scripts samples and scripts descriptions.
Monday, February 21, 2011
Function for generation accept string in Web Human Emulator.
Example for generate and set browser data - Accept, User Agent etc.
Thursday, February 10, 2011
Remote work with the Human Emulator.
Not all users of Human Emulator aware of the fact that the control program can be made remote. That is, Human Emulator stands at some server, and you are from a browser or from the php scripts on your computer can run a human scripts. Or, Human Emulator sofware stands on one computer of the local network at the office , but you can from your laptop to manage this Human Emulator. In this case, all actions for the server and network are the same.
Assume that Human Emulator stands on server with ip 93.95.108.1 on port 7010. The program is open and ready for work.
The easiest way, requiring no further action is to call the commands from your browser. Just take, and type in the browser so that's a line http://93.95.108.1:7010/Browser.Navigate?url=google.ru Human Emulator on the server magically went to google.com. If you enter the following commands:
http://93.95.108.1:7010/Browser.Navigate?url=http% 3A% 2F% 2Fgoogle.com & use_cache = 1
http://93.95.108.1:7010/Input.SetValueByName?name=q&value=human
http://93.95.108.1:7010/InputButton.ClickByNumber?number=0
a Human Emulator on the server goes to google.com in the search box to add the word human and clicks on the search button.
In the script of Human these lines will look like this:
$browser->navigate('http://google.com');
$input->set_value_by_name('q',"human".$i);
$button->click_by_number(0);
In order that would in the usual form to get the team to enter the browser enough to open the information panel (View) and a script run.
The second method requires the installation program templates Human Emulator on the computer from which the remote control. To do this, just enough to where you copy a folder from the Templates folder of Human Emulator. Next from the command line php script executes the following code:
And on the server Human software execute this script.
Another way to manage remotely, is to add script Human Emulator in the pages of your site and the user pressing any elements can run this script and execute it Human Emulator.
And the last way to remote control it's startup scripts in human software, which stands on PC, and these scripts will be executed on the server. It's enough to be set in the beginning of the script string $ xhe_host = "93.95.108.1:7010"; as in the example script above.
Assume that Human Emulator stands on server with ip 93.95.108.1 on port 7010. The program is open and ready for work.
The easiest way, requiring no further action is to call the commands from your browser. Just take, and type in the browser so that's a line http://93.95.108.1:7010/Browser.Navigate?url=google.ru Human Emulator on the server magically went to google.com. If you enter the following commands:
http://93.95.108.1:7010/Browser.Navigate?url=http% 3A% 2F% 2Fgoogle.com & use_cache = 1
http://93.95.108.1:7010/Input.SetValueByName?name=q&value=human
http://93.95.108.1:7010/InputButton.ClickByNumber?number=0
a Human Emulator on the server goes to google.com in the search box to add the word human and clicks on the search button.
In the script of Human these lines will look like this:
$browser->navigate('http://google.com');
$input->set_value_by_name('q',"human".$i);
$button->click_by_number(0);
In order that would in the usual form to get the team to enter the browser enough to open the information panel (View) and a script run.
The second method requires the installation program templates Human Emulator on the computer from which the remote control. To do this, just enough to where you copy a folder from the Templates folder of Human Emulator. Next from the command line php script executes the following code:
<?php
$xhe_host ="93.95.108.1:7010";
// The following code is required to properly run XWeb Human Emulatorrequire("../Templates/xweb_human_emulator.php");
$browser->navigate('http://google.com');
// wait on browser
$browser->wait_for(30,1);
for($i;$i<?50;$i++)
{
$browser->navigate('http://google.com');
// wait on browser
$browser->wait_for(30,1);
$input->set_value_by_name('q',"human".$i);
$button->click_by_number(0);
// wait on browser
$browser->wait_for(30,1);
echo $i."";
// go to blank page
$browser->navigate('about:blank');
// wait on browser
$browser->wait_for(30,1);
}
// Quit
$app->quit();
?>
And on the server Human software execute this script.
Another way to manage remotely, is to add script Human Emulator in the pages of your site and the user pressing any elements can run this script and execute it Human Emulator.
And the last way to remote control it's startup scripts in human software, which stands on PC, and these scripts will be executed on the server. It's enough to be set in the beginning of the script string $ xhe_host = "93.95.108.1:7010"; as in the example script above.
Tuesday, December 1, 2009
Using of proxy with the Web Human Emulator.
A proxy need. Very, very need! Do not want some Bookmarks services enable to 5 messages of 300 users per hour! They write - you have too many complaints from the same IP.
So we have to use a proxy server.
In the Web Human Emulator for work with proxy using "browser" object functions:
$browser->enable_proxy("all connections","proxy"); and $browser->disable_proxy("all connections");
For more information about these functions, see the program documentation.
So we have a file with a proxy, and we need somewhere to leave messages for each proxy. To do this, we first obtain this proxy list from a file into an array with the following code:
$proxy=file("proxy");
All of our proxies are added to the array. Now write a loop to obtain the proxy and install it on the connection:
for($i=0;$ienable_proxy("all connections",$proxy[$i]);
// check connection via proxy
// if can't connect to google
// go to next proxy
if (!$browser->check_connection('http://www.google.com',30))
continue;
// post message code here
}
In end of script need add follow code :
$browser->disable_proxy("all connections");
In WHE:
So we have to use a proxy server.
In the Web Human Emulator for work with proxy using "browser" object functions:
$browser->enable_proxy("all connections","proxy"); and $browser->disable_proxy("all connections");
For more information about these functions, see the program documentation.
So we have a file with a proxy, and we need somewhere to leave messages for each proxy. To do this, we first obtain this proxy list from a file into an array with the following code:
$proxy=file("proxy");
All of our proxies are added to the array. Now write a loop to obtain the proxy and install it on the connection:
for($i=0;$i
// check connection via proxy
// if can't connect to google
// go to next proxy
if (!$browser->check_connection('http://www.google.com',30))
continue;
// post message code here
}
In end of script need add follow code :
$browser->disable_proxy("all connections");
In WHE:
Friday, November 27, 2009
Script for twitter.com regstration.
It is a simple script-regestrator for Twitter.com.The script automatically fill data fields and shows a dialog input captcha. If you have access to whatever service recognition CAPTCHA, then this service can be connected to this script.
PHP code:
?php
// The following code is required to properly run Web Human Emulator
require("../Templates/xweb_human_emulator.php");
//////////////////////// settings for scripts
// name
$usr_name ="name";
// login
$usr_login = "login";
// password
$usr_pwd = "password";
// mail
$usr_mail = "mail";
// message
$usr_message = "message";
//////////////////////////////////////////////////////////
// go to twitter
$browser->navigate('twitter.com');
$browser->wait_for(240,1);
// go to registration
$anchor->click_by_inner_text('Sign up now','true');
$browser->wait_for(240,1);
// set name
$input->set_value_by_name('user[name]',$usr_name);
// set login
$input->set_value_by_name('user[screen_name]',$usr_login);
// set password
$input->set_value_by_name('user[user_password]',$usr_pwd);
// set mail
$input->set_value_by_name('user[email]',$usr_mail);
////////////////////////////////////// recognize recatcha
$pref ="src=\"https://api-secure.recaptcha.net/image?c=";
$pref1 ="\" width=";
$text = $webpage->get_body();
$ind = strpos($text,$pref);
$ind1 = strpos($text,$pref1,$ind);
$cod = substr($text,$ind+strlen($pref),$ind1-$ind-strlen($pref));
$url_captcha = "https://api-secure.recaptcha.net/image?c=".$cod;
$captcha = $app->dlg_captcha_from_url_exactly($url_captcha,"false");
// set captcha
$input->set_value_by_name("recaptcha_response_field",$captcha);
//////////////////////////////////////////////////////////////////////////////////////
// register
$button->click_by_name('commit');
$browser->wait_for(240,1);
// skip next step
$anchor->click_by_inner_text('Skip this step','true');
$browser->wait_for(240,1);
// apply all
$button->click_by_name('commit');
$browser->wait_for(240,1);
// set message
$textarea->set_value_by_name('status',$usr_message);
// update message on twitter
$button->click_by_name('update');
$browser->wait_for(240,1);
// Quit
$app->quit();
?>
PHP code:
?php
// The following code is required to properly run Web Human Emulator
require("../Templates/xweb_human_emulator.php");
//////////////////////// settings for scripts
// name
$usr_name ="name";
// login
$usr_login = "login";
// password
$usr_pwd = "password";
$usr_mail = "mail";
// message
$usr_message = "message";
//////////////////////////////////////////////////////////
// go to twitter
$browser->navigate('twitter.com');
$browser->wait_for(240,1);
// go to registration
$anchor->click_by_inner_text('Sign up now','true');
$browser->wait_for(240,1);
// set name
$input->set_value_by_name('user[name]',$usr_name);
// set login
$input->set_value_by_name('user[screen_name]',$usr_login);
// set password
$input->set_value_by_name('user[user_password]',$usr_pwd);
// set mail
$input->set_value_by_name('user[email]',$usr_mail);
////////////////////////////////////// recognize recatcha
$pref ="src=\"https://api-secure.recaptcha.net/image?c=";
$pref1 ="\" width=";
$text = $webpage->get_body();
$ind = strpos($text,$pref);
$ind1 = strpos($text,$pref1,$ind);
$cod = substr($text,$ind+strlen($pref),$ind1-$ind-strlen($pref));
$url_captcha = "https://api-secure.recaptcha.net/image?c=".$cod;
$captcha = $app->dlg_captcha_from_url_exactly($url_captcha,"false");
// set captcha
$input->set_value_by_name("recaptcha_response_field",$captcha);
//////////////////////////////////////////////////////////////////////////////////////
// register
$button->click_by_name('commit');
$browser->wait_for(240,1);
// skip next step
$anchor->click_by_inner_text('Skip this step','true');
$browser->wait_for(240,1);
// apply all
$button->click_by_name('commit');
$browser->wait_for(240,1);
// set message
$textarea->set_value_by_name('status',$usr_message);
// update message on twitter
$button->click_by_name('update');
$browser->wait_for(240,1);
// Quit
$app->quit();
?>
Ярлыки:
scripts
Thursday, November 26, 2009
Working with files and organization of the loop in Web Human Emulator.
Often we need to read data from a file and setting of the cycle in a field. Write a simple script that will say read from the file search requests entered into Google search box and click on the search button.
First, we'll create a script using the File menu, click New Menu. In the editor php-stream program will open a new tab with the following code:
? php
// The following code is required to properly run XWeb Human Emulator
require ("../Templates/xweb_human_emulator.php ");
// Navigate to google
$browser->navigate("http://www.google.com");
// Wait on browser
$browser->wait(1);
// Quit
$app->quit();
?>
If you run this script, then the browser program will open Google.
Now the mouse cursor is over in the search box, we click the right mouse button and see the popup menu.
One of the items is $input leads to another menu, it separates the functions for the object $input. Click on the $input->set_value_by_name("q ",""); menu and this string appears in the php editor. Do the same with the "Search Google" button. Context menu $button and drop-down menu choose $button->click_by_name("btnG");. This line is added to the editor in the script.
Note: before inserting thus function, place the cursor at the location where you want the script to insert the otherwise it will be inserted where there is currently the cursor!
Immediately after the function $button->click_by_name("btnG"); add $browser->wait(1);. This function is mandatory after every function of transition or upgrade your browser. She expects until the browser will perform specified actions, and then executes the script further.
Now the script looks as follows:
? php
// The following code is required to properly run XWeb Human Emulator
require ("../ Templates / xweb_human_emulator.php ");
// Navigate to google
$browser->navigate("http://www.google.com");
// Wait on browser
$browser-> wait (1);
$input->set_value_by_name ( "q ","");
$button->click_by_name ( "btnG");
$browser->wait (1);
// Quit
$app->quit();
?>
When executed, this script is an empty string is entered in the search box and clicks the Search button.
Now connect queries from a file and will introduce them in the search box in the cycle.
For this first prochiatem file into an array with the following code:
$arr_search = file("c:\\search_string.txt")
If the file is asking for is in the same folder as the script then absolutely path may be omitted and the code is as follows:
$arr_search = file("search_string.txt")
Function PHP file reads each line of the file in a separate element of the array.
Now organize a cycle based on the number of elements in the array, ie kolichesvto lines read from the file:
loop - for($i = 0; $i < ($arr_search); $i++)
loop body - ()
that would get the current element masciva must add this code that's $arr_search[$ i]
eventually have the following code:
? php
// The following code is required to properly run XWeb Human Emulator
require ("../ Templates / xweb_human_emulator.php ");
// Read data from a file into an array
$arr_search = file ( "search_string.txt")
// Organize the script
for ($i = 0; $i < ($arr_search); $i++)
{
// Navigate to google
$browser->navigate("http://www.google.com");
// Wait on browser
$browser->wait(1);
// Print request to the debug window
echo $arr_search[$i]. "br>";
// Enters a query into the search box
$input->set_value_by_name("q", $ arr_search [$ i]);
// Push the search button
$button->click_by_name ( "btnG");
$browser->wait(1);
// Look at the results of 5 seconds:)
sleep (5);
// ... here you can continue to do anything with the results of search to gather them in a file
// Go to each site and parse the text in the file, etc.
}
// Quit
$app->quit();
?>
When you run the script to execute script reads all rows from the file search_string.txt set into the search field and clicks on the Search button, after waits 5 seconds and moves on.
First, we'll create a script using the File menu, click New Menu. In the editor php-stream program will open a new tab with the following code:
? php
// The following code is required to properly run XWeb Human Emulator
require ("../Templates/xweb_human_emulator.php ");
// Navigate to google
$browser->navigate("http://www.google.com");
// Wait on browser
$browser->wait(1);
// Quit
$app->quit();
?>
If you run this script, then the browser program will open Google.
Now the mouse cursor is over in the search box, we click the right mouse button and see the popup menu.
One of the items is $input leads to another menu, it separates the functions for the object $input. Click on the $input->set_value_by_name("q ",""); menu and this string appears in the php editor. Do the same with the "Search Google" button. Context menu $button and drop-down menu choose $button->click_by_name("btnG");. This line is added to the editor in the script.
Note: before inserting thus function, place the cursor at the location where you want the script to insert the otherwise it will be inserted where there is currently the cursor!
Immediately after the function $button->click_by_name("btnG"); add $browser->wait(1);. This function is mandatory after every function of transition or upgrade your browser. She expects until the browser will perform specified actions, and then executes the script further.
Now the script looks as follows:
? php
// The following code is required to properly run XWeb Human Emulator
require ("../ Templates / xweb_human_emulator.php ");
// Navigate to google
$browser->navigate("http://www.google.com");
// Wait on browser
$browser-> wait (1);
$input->set_value_by_name ( "q ","");
$button->click_by_name ( "btnG");
$browser->wait (1);
// Quit
$app->quit();
?>
When executed, this script is an empty string is entered in the search box and clicks the Search button.
Now connect queries from a file and will introduce them in the search box in the cycle.
For this first prochiatem file into an array with the following code:
$arr_search = file("c:\\search_string.txt")
If the file is asking for is in the same folder as the script then absolutely path may be omitted and the code is as follows:
$arr_search = file("search_string.txt")
Function PHP file reads each line of the file in a separate element of the array.
Now organize a cycle based on the number of elements in the array, ie kolichesvto lines read from the file:
loop - for($i = 0; $i < ($arr_search); $i++)
loop body - ()
that would get the current element masciva must add this code that's $arr_search[$ i]
eventually have the following code:
? php
// The following code is required to properly run XWeb Human Emulator
require ("../ Templates / xweb_human_emulator.php ");
// Read data from a file into an array
$arr_search = file ( "search_string.txt")
// Organize the script
for ($i = 0; $i < ($arr_search); $i++)
{
// Navigate to google
$browser->navigate("http://www.google.com");
// Wait on browser
$browser->wait(1);
// Print request to the debug window
echo $arr_search[$i]. "br>";
// Enters a query into the search box
$input->set_value_by_name("q", $ arr_search [$ i]);
// Push the search button
$button->click_by_name ( "btnG");
$browser->wait(1);
// Look at the results of 5 seconds:)
sleep (5);
// ... here you can continue to do anything with the results of search to gather them in a file
// Go to each site and parse the text in the file, etc.
}
// Quit
$app->quit();
?>
When you run the script to execute script reads all rows from the file search_string.txt set into the search field and clicks on the Search button, after waits 5 seconds and moves on.
Ярлыки:
scripts
Wednesday, November 25, 2009
Script for search data through Google. Part1.
With Web Human Emulator you can find and collect various information using the search engine Google.
Let's write a script.
First of all you create a new script using the menu New. The result is the following code:

Then we run the script is executed using the Run button or hot key F5. After running the script in the browser will open Google:

Set the cursor in the php editor to line 9 and then select the Google search box. After, click on the field right mouse button and result we get context menu:

Push the menu $input, and we see the menu with functions for this object.

We click on the $input->set_value_by_name("q ",""); menu item and this line appears in the PHP editor and we have next code in the PHP editor:

Add a search word or phrase in the function $input->set_value_by_name("q ",""); and have for example $input->set_value_by_name("q","car for sale");. Run script for execution and eventually have such a result.

After we click the right mouse button on the button "Search in Google" and see the popup menu.

Roll over $button and see a drop-down menu with the object $button functions. Click on $button->click_by_name("btnG");. This line appears in the PHP editor. Copy string $browser->wait(1); and paste it after $button->click_by_name("btnG"); In result we have follow code:

Run the script and we have next result:

Thus we have the first part of the script - search for a specific query in Google and receive search results. Now we need to write a second part to find needed information and parsing it in the needed format. To be continued ...
Let's write a script.
First of all you create a new script using the menu New. The result is the following code:
Then we run the script is executed using the Run button or hot key F5. After running the script in the browser will open Google:
Set the cursor in the php editor to line 9 and then select the Google search box. After, click on the field right mouse button and result we get context menu:
Push the menu $input, and we see the menu with functions for this object.
We click on the $input->set_value_by_name("q ",""); menu item and this line appears in the PHP editor and we have next code in the PHP editor:
Add a search word or phrase in the function $input->set_value_by_name("q ",""); and have for example $input->set_value_by_name("q","car for sale");. Run script for execution and eventually have such a result.
After we click the right mouse button on the button "Search in Google" and see the popup menu.
Roll over $button and see a drop-down menu with the object $button functions. Click on $button->click_by_name("btnG");. This line appears in the PHP editor. Copy string $browser->wait(1); and paste it after $button->click_by_name("btnG"); In result we have follow code:
Run the script and we have next result:
Thus we have the first part of the script - search for a specific query in Google and receive search results. Now we need to write a second part to find needed information and parsing it in the needed format. To be continued ...
Ярлыки:
scripts
Tuesday, November 24, 2009
Script for register you web site to 3 Search Engines
I wrote script for register my site to 3 Seach Engines - MSN(Bing),Google and Yahoo.
PHP code:
// The following code is required to properly run Web Human Emulator
require("../../Templates/xweb_human_emulator.php");
// This script submit your site to 3 Search Engines
// Google
// MSN
// Yahoo
// for request more SE please write to humanemulator@gmail.com
// ======================= COMMON INFO =================
$title="title";
$url="http://www.sitebred.com/";
$comments="comments";
$contact_face="name";
$contact_mail="mal@mail.com";
// ======================================================
// ======================= GOOGLE ======================
// goto to add page
$browser->navigate("http://www.google.com/addurl/?continue=/addurl");
$browser->wait(1);
// add reg info
$input->set_value_by_number(1,$url);
$input->set_value_by_number(2,$title);
$captcha=$app->dlg_captcha_from_image_number(7);
$input->set_value_by_name("captcha",$captcha);
$button->click_by_number(1);
$browser->wait(1);
// ======================================================
// ======================= MSN ==========================
// goto to add page
$browser->navigate("http://www.bing.com/docs/submit.aspx");
$browser->wait(1);
// add reg info
$input->set_value_by_name("url",$url);
$captcha=$app->dlg_captcha_from_image_number(0);
$input->set_value_by_name("h",$captcha);
$button->click_by_name("submit_url");
$browser->wait(1);
// ======================================================
// ======================= YAHOO ========================
// goto to add page
$browser->navigate("https://siteexplorer.search.yahoo.com/submit");
$browser->wait_for(10,1);
$anchor->click_by_inner_text("Submit a Website or Webpage","true");
$browser->wait_for(10,1);
// add reg info
$input->set_value_by_name("site_url",$url);
$button->click_by_inner_text("Submit URL");
$browser->wait_for(10,1);
// ======================================================
// Quit
$app->quit();
Object Description from this script:
browser - object for work with WHE browser (navigate to website,wait for load web page etc)
input - object for work with INPUT elements of web page (set value, get value etc)
app - object for manage WHE application and captcha dialogs
button - object for work with INPUT (type button) elements of web page (press button, set focus etc)
anchor - object for work with links (A tag)of web page (click. get text etc)
PHP code:
// The following code is required to properly run Web Human Emulator
require("../../Templates/xweb_human_emulator.php");
// This script submit your site to 3 Search Engines
// MSN
// Yahoo
// for request more SE please write to humanemulator@gmail.com
// ======================= COMMON INFO =================
$title="title";
$url="http://www.sitebred.com/";
$comments="comments";
$contact_face="name";
$contact_mail="mal@mail.com";
// ======================================================
// ======================= GOOGLE ======================
// goto to add page
$browser->navigate("http://www.google.com/addurl/?continue=/addurl");
$browser->wait(1);
// add reg info
$input->set_value_by_number(1,$url);
$input->set_value_by_number(2,$title);
$captcha=$app->dlg_captcha_from_image_number(7);
$input->set_value_by_name("captcha",$captcha);
$button->click_by_number(1);
$browser->wait(1);
// ======================================================
// ======================= MSN ==========================
// goto to add page
$browser->navigate("http://www.bing.com/docs/submit.aspx");
$browser->wait(1);
// add reg info
$input->set_value_by_name("url",$url);
$captcha=$app->dlg_captcha_from_image_number(0);
$input->set_value_by_name("h",$captcha);
$button->click_by_name("submit_url");
$browser->wait(1);
// ======================================================
// ======================= YAHOO ========================
// goto to add page
$browser->navigate("https://siteexplorer.search.yahoo.com/submit");
$browser->wait_for(10,1);
$anchor->click_by_inner_text("Submit a Website or Webpage","true");
$browser->wait_for(10,1);
// add reg info
$input->set_value_by_name("site_url",$url);
$button->click_by_inner_text("Submit URL");
$browser->wait_for(10,1);
// ======================================================
// Quit
$app->quit();
Object Description from this script:
browser - object for work with WHE browser (navigate to website,wait for load web page etc)
input - object for work with INPUT elements of web page (set value, get value etc)
app - object for manage WHE application and captcha dialogs
button - object for work with INPUT (type button) elements of web page (press button, set focus etc)
anchor - object for work with links (A tag)of web page (click. get text etc)
Ярлыки:
scripts
Subscribe to:
Posts (Atom)