Variables mentioned below should be treated as constants. Because of javascript flexibility we can not disallow you to change them in your code. But all changes will have absolutely no effect.
debug
Integer, debug level (sometimes called verbose level). Corresponds to -vN command line parameter.
Useful when you need to hide debug/test messages when running in release mode.
Default value: 0
Example:
if( debug >= 2)
Print( "Sbcore version is ", version );
directory
String, current application directory, without trailing slash
It can be changed with -d command line parameter under Windows and Linux.
For Android it's something like: /storage/emulated/0/Android/data/com.scraper/files.
Example:
Write( directory + "/test.txt", "Hello, world!" );
version
String, current Scrapper application version.
Example:
Print( version );
computer
Object. Information about current device. It has the following fields:
computer.uuid | 32-character string. MD5 hash of unique computer identifier. Different devices will have different UUID. |
computer.mac | 12-character string. mac-address of computer's NIC. |
computer.os.name | Operating system name. One of the following: Windows, Linux, Android |
computer.os.version | String. Operating system version. |
computer.device | String. Device name. Available for Android only. |
Example:
if( "Android" == computer.os.name)
Print( "Hello, Android!" );
storage
Object. Application local storage. Storage file may be specified either in command line with -s parameter, or with Load method. Storage is the same for all workers. It has the following methods:
Get ( key ) | returns the value previously set with Set |
Set ( key, value ) | sets value for specified key |
All ( ) | reurnd JSON of all key-value pairs |
Load ( fpath ) | Loads the data from give path. Also, this path will be used for saving data back to file. |
Example:
// set storage file
storage.Load("storage_file");
// get previous value
var str_counter = storage.Get("counter");
// convert it to number
var counter = str_counter ? parseInt(str_counter) : 0;
// increment it
counter++;
// save it back. Note: second parameter is string.
storage.Set("counter", counter.toString());
// This will output incremented number every new run of the application
Print("Counter : ", counter);
// Now, let's see what is is storage
var all = storage.All();
Print("Storage content: ", JSON.stringify(all));
// The output:
Counter : 3
Storage content: { "counter": "3" }
proxyCheckerURL
This is special URL of the proxy checker service we developed. It returns simple JSON like this:
{
"address": {
"remote":"127.0.0.1",
"forwarded":"127.0.0.1",
"real":"127.0.0.1"
}
}
remote | remote address of endpoint |
forwarded | X-Forwarded-For value of HTTP header. Optional. |
real | X-Real-IP value of HTTP header. Optional. |
Here is a sample code of simple proxy checker.
See also
|