To create templates for autoposting in Zebroid on most not so difficult, often created templates by people who never did that before. But in certain cases nevertheless skills of programming are necessary. In this article principles and accessible functional for creation of the templates of Autoposting are described.
For those who have no desire or abilities to create such scripts there is
a theme of orders a spelling of scripts in the closed branch of the program at a forum. But it is necessary to understand that a priority of such orders before the basic work on the program much more low.
First of all it is necessary to open an autoposting window, tab «Creation of templates» and to add the template. It is recommended, that any project for Zebroid that at once it was possible to test scripts has already been loaded.
Creation of templates
Window of creation of scripts of autoposting
On this tab scripts for posting are created. Here we have the list of templates and their editor. The editor consists from 2 parts:
- Editor of a script
- Editor of additional fields and test variables
The first is responsible for algorithm of work of a template of posting (more detailed about all procedures and to variables it is possible to find in following parts of this article), the second — for presence of those or other fields in a body of a script and for the data necessary for the test of a script for working capacity.
I will stop on the editor of additional fields as for its use the knowledge of a format of record is necessary. So a format following (each new record since a new line):
VARIABLE_NAME=DESCRIPTION|DEFAULT_VALUE
Variable Name can be any. It as a matter of fact that the program searches before script start to replace with value.
the description is what to see the user in the list доп. Fields which it is necessary for it to fill at account creation.
value by default is a value which is established before the user will enter the. During the test, the program uses value by default at filling доп. Fields.
Since the version of the program 4.5 in Zebroid there is browser Chromium support (was Internet Explorer earlier). At creation of scripts there is a choice for what of browsers to do a script, but it is recommended to use only Chromium as Internet Explorer in the future it will be cleaned. At present support of this browser exists for return compatibility and possibility to translate the scripts under a new cursor.
Syntax of scripts
In autoposting scripts it is used Pascal syntax. Almost all accessible functions of this programming language are realised. Besides ready functions for management of the browser from the program and work with the project are added.
Ready functions are conditionally divided into 3 groups:
- Cores
- Additional
- Functions of a professional mode of posting (the out-of-date mode, in Chromium is not used and in the future it will be cleaned)
The first comprise the most necessary functions for work with the project and posting on sites. The second — additional functions which happen are seldom claimed. The third — functions of work of a script in a mode of the professional (it is a mode in which the program transfers full control to a script and does not interfere with its work).
Standard variables:
- $POST_TITLE — a record name
- $POST_CATEGORY — a name of parental record
- $POST_TEXT — the record text
- $POST_BRIEF — the post announcement (the text to тега <undertakes! — more->)
- $POST_TAGS — таги records
- $CAT_NAME — a category name (basically one and too as $POST_TITLE)
- $POST_DATE — full date of the publication
- $POST_YEAR — year of the publication
- $POST_MONTH — month of the publication
- $POST_DAY — day of the publication
- $POST_HOUR — hour of the publication
- $POST_MINUTES — minutes of the publication
- $POST_ALT_NAME — URL article name
- $POST_META_KEYS — meta keywords
- $POST_META_DESC — meta description
- $__the NAME — value add. fields with a name the NAME (the name can be any)
- $URL — values of a field «the site Address»
- $LOGIN — values weeding «Login»
- $PASSWORD — values weeding «Password»
- $NAME — values of an additional field of a script
Attention: the Given variables cannot be used out of compulsory procedures Posting and AddCategories (or procedures which they cause).
Compulsory procedures:
procedure Login();//login procedure on a site
procedure Posting();//procedure of addition of posts
procedure GoToCatSetings();//calling in admin panel where categories are added
procedure AddCategories();//procedure of addition of categories
Main functions
{
To pass to the specified page
@param string url - The page address
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure Navigate (url:string; WaitForLoad:boolean);
{
Adds support zQuery (jQuery for Zebroid) for the flowing
Villages. The call of functions in JS scripts is carried out through
The reference to function zQuery (instead of jQuery and $).
}
procedure InjectZQuery ();
{
To fill a form field
@param string field - A field name
@param string value - Value
}
procedure FillForm (field, value:string);
{
To fill all fields on page which have the filled out name
@param string field - A field name
@param string value - Value
}
procedure FillFormAll (field, value:string);
{
Search value in the dropping out list (the found value
Gets out)
@param string field - A list name
@param integer indx - A point index (since 0),
Which needs to be chosen
}
procedure FillComboboxByIndex (field:string; indx:integer);
{
Search value in the dropping out list (the found value
Gets out)
@param string field - A list name
@param string value - Value of parametre value,
Which needs to be chosen
}
procedure FillComboboxByValue (field, value: string);
{
Search value in the dropping out list (the found value
Gets out)
@param string field - A list name
@param string item - The point text in the list,
Which needs to be chosen
}
procedure FillComboboxByItem (field, item: string);
{
To attach to the form a file
@param string field - A field for a file
@param string filepath - A full way to a file on the computer
}
procedure SetFile (field, filepath: string);
{
To receive the list of all pictures in article text. The result is issued
In the form of the list of names of pictures and through tabulation a full way to a file
On the computer of the user
}
function GetPostImages ():string;
{
To press the button
@param string btn - A button name
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure ClickButton (btn:string; WaitForLoad:boolean);
{
To press the button
@param string btn - A button name
@param integer numb - Number of the button with such name on page
(Since 0)
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure ClickButtonByNumber (btn:string; numb:integer; WaitForLoad:boolean); ')
{
To press the button
@param string button_id- id buttons
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure ClickElementById (button_id:string; WaitForLoad:boolean);
{
Сабмит forms at specified number
@param integer name - A form name
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure SubmitFormByName (name:string; WaitForLoad:boolean);
{
Emulation a clique on JS to object
@param string js_object- Object JS for which needs to be feigned cliques
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure ClickSimulate (js_object:string; WaitForLoad:boolean);
{
Emulation of pressing of a key
@param integer mode- Message Type (0 - key pressing, 1 - отпускание keys, 2 - to send a symbol)
@param boolean key- ASCI a key code (for example 13 - Enter, 32 - a blank)
}
procedure KeyPress (mode, key: integer);
{
Сабмит forms at specified number
@param integer form - Form serial number (begins with zero)
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure SubmitFormByIndex (index:integer; WaitForLoad:boolean);
{
To suspend script performance
@param byte sec - Pause time in seconds
}
procedure Wait (sec:byte);
{
Search value in the initial text of page (returns value
The specified group). Works before the first coincidence;
@param string reg - Regular expression on which
It is necessary to spend search
@param integer numb - Group number which value
It will be returned (0 - result
All regular expression)
}
function SearchInSource (reg:string; numb:integer):string;
{
Returns value of the specified variable from the list
Standard variables
@param string value - A variable name
}
function GetVar (value:string):string;
{
To shield спецсимволы regular expression
@param string s - A line which is necessary for shielding
}
function EscapeChars (s:string):string;
{
To execute JavaScript
@param string script - The script text
@param boolean WaitForLoad - To wait the end of loading of page
}
procedure ExecJS (script:string; WaitForLoad:boolean);
{
To execute JavaScript and returns text result
@param string script - The script text
}
function ExecJSWithResult (script:string):string;
{
Returns HTML a page code
}
function GetHTML ():string;
{
Conclusion of a window with the request to enter captcha. The script will not continue work while captchawill not be entered
@param string url - A part captcha url (a unique part for the given page precisely to identify drawing каптчи)
@param string field - The field where should is brought result of input
}
procedure CapthcaBox (url, field:string);
{
Expectation of occurrence HTML of a code on page (gives the chance to identify precisely the end of loading of page)
@param string html - HTML the code, which occurrence is expected (the register does not matter)
}
procedure WaitForHTML (html:string);
{
Conclusion of the message with a question and buttons OK, Cancellation. Returns value 1 if have pressed ОК and 0 - if Cancellation.
@param string text - The message/question test
}
function MsgBox (text:string):integer;
{
Keeps the text in a file
@param string text - The text which is necessary for keeping
@param string filename - A full way to a file for preservation (if the file exists - that it will be rewritten)
}
procedure SaveToFile (text, filename:string);
{
To keep a broad gull of actions of a script in a file
@param string filename - A full way to a file for preservation (if the file exists - that it will be rewritten)
}
procedure SaveLog (filename:string);
{
Translates the text with HTML in BB
@param string html - The text which it is necessary to translate in BB
}
function HtmlToBB (html:string):string;
{
Deletes all HTML from the text
@param string str - The text in which is necessary for removing HTML
}
function NoHTML (str: string):string;
{
Function of search and replacement in the text, returns result
@param string find - What to search
@param string replace - On what to replace
@param string replace - The text in which will be search is made
@param boolean WholeWord - To process only the whole words
@param boolean CaseSenc - Case sensitivity
@param smallint repl_type - Search type: 0 - usual search, 2 - regular expressions
}
function RegEx (find, replace, subject:string; WholeWord, CaseSenc:boolean; repl_type:smallint):string;
{
Installation to radio-boxing with a name name values value
@param string name - A radio-boxing name
@param string value - Value
}
procedure RadioCheck (name:string; value:string);
{
To change value of checkbox
@param string chb - A name of checkbox
@param boolean status - Value (true - to allocate; false - to remove selection)
}
procedure ChechBoxCheck (chb:string; status:boolean);
{
Compulsory expectation of the termination of loading of page. It is recommended to use at sending of pressing of button Enter that the nobility when loading has come to the end. If the page was not loaded, but have caused this procedure it will come to the end on the expiration таймаута (about 30 seconds)
}
procedure WaitForLoad ();
{
To write the message to a broad gull window
@param string mess - The message text
}
procedure WriteToLog (mess:string);
{
Sending captcha on solving to a resource http://antigate.com/. Returns result of solving
@param string key - A key of the user antigate.com
@param string img - A part of captcha url(a unique part for the given page precisely to identify drawing captcha)
}
function AntiCaptcha (key, img:string):string;
{
Installation of parametres of sending каптчи in service antigate.com (the description of each of parameters look here: http://antigate.com/panel.php?action=api)
}
procedure SetCaptchaParams (phrase, regsense, numeric, calc, min_len, max_len:integer);
{
To report on an error of solving of last from captcha.
}
procedure ReportBadCaptcha ();
{
Returns true if record has the draught copy status.
}
function isDraftPost ():boolean;
{
Copies an initial code of page in a clipboard
}
procedure SourceToClipboard ();
{
Does not mark record as used on end of work of a script
}
procedure DoNotCheckAsUsed ();
{
Record of the reference to a post. On the posting termination it is possible to look at all published references in a file "temp \__autoposting_urls"
@param string url - Value which will be written down in a file
}
procedure AddUrl (url:string);
Functions that works with Excel
{
Loads file contents
@param string FileName - A full way to a file
}
procedure Excel_LoadFile (FileName: string);
{
Keeps file contents
@param string FileName - A full way to a file
}
procedure Excel_SaveFile (FileName: string);
{
Returns cell contents
@param string col - Alphabetic representation of a column (A, B, C...)
@param integer row - A line number (since zero)
}
function Excel_ReadCell (col: string; row: integer):string;
{
Writes down in a cell value value
@param string col - Alphabetic representation of a column (A, B, C...)
@param integer row - A line number (since zero)
@param string value - Value which needs to be written down
}
procedure Excel_WriteCell (col: string; row: integer; value: string);
Attention: to Work with these functions is better since function Excel_LoadFile even if you need to keep nothing. By a call of this function the program remembers on expansion of a file with what type to it it is necessary to work further and on it depends in what format will be preservation is made.
Example of loading and work with a file:
Excel_LoadFile ('C:\myfile.xls');//we Open a file
buf: = Excel_ReadCell ('A',0);//It is read out cell contents in a variable buf
WriteToLog (buf);//It is deduced contained in a broad gull
Preservation example in a new file:
Excel_LoadFile ('.xlsx');//It is necessary, that we will establish with what format to work
Excel_WriteCell ('A',0,' Hello world!!! ');//It is written down in a cell
Excel_SaveFile ('C:\myfile.xlsx');//It is kept in a file
Professional mode of posting
The ABM a mode is a mode for skilled coders which are capable to understand the documentation of its use, have skills of programming and all consequences of use of this mode incur.
That includes the ABM a mode:
- any restrictions
- full access to the project data
- additional possibilities of management of a posting window
The program defines presence of the ABM of a mode of a time to the first line of a script of posting, namely it should be that:
Program InProffesionalMode;
The performance order опреаций in the ABM a mode is defined by a design «begin end.»
I.e. the pig of the ABM of a mode looks as follows:
Program InProffesionalMode;
//Procedures and functions here
begin
//the Order of performance of procedures and functions here
end.
Data at the disposal of scripts in the ABM a mode
And now we will look that is in the ABM a mode:
1.
the data file «records» is a data file of the current project (all elements of a tree and their characteristic) . Has a number of properties and functions which help to operate with the data. Properties and methods:
- Count — quantity of records
- ItemTitle [Index:Integer]: string — the record Name at number Index
- ItemAltName [Index:Integer]: string — Attribute AltName of record at number Index
- ItemKeywords [Index:Integer]: string — record Keywords at number Index
- ItemDescription [Index:Integer]: string — the record Description at number Index
- ItemText [Index:Integer]: string — the record Text at number Index
- ItemConvText [Index:Integer]: string — Converted the text (are translated drawings from a program format in addresses on a site, internal references leave) records at number Index
- ItemTags [Index:Integer]: string — record Labels at number Index
- ItemDate [Index:Integer]: string — record Date at number Index
- ItemUsed [Index:Integer]: boolean — Attribute used records at number Index (it is necessary for prevention of repeated posting of record)
- IsCategory [Index: Integer]: boolean — whether Defines record by a category
is- GetParentIndx [Index: Integer]: Integer — Returns an index of the parent of record. If It is record of the first level (i.e. there is no parent) returns-1
2.
management of properties and controllers posting windows. Object is caused by name «Window». Properties and methods:
- PBmax: Integer — the Maximum value bar Progress
- PBposition: Integer — a current position bar Progress
- JustNew: boolean — Value of an option «to Add only not used posts and categories»
- procedure PBgo (Value:integer); — to change a position bar Progress to value Value