PixieRobot: WWW Help
PixieRobot now provides a script interface for driving a browser object. You can script:
Programming a conversation: in
brief
Scripts are plain text
files written in the VBSCRIPT language. By default the browsing script is
called "onInterval.txt"
but you can change its name with entries like this in
"PixieRobot.ini", section "[WWW]":
ScriptOnInterval=Cleopatra.txt
You need to name your master routine
Sub
Main
The script statement Monitor=True causes the conversation to be
made visible.
Monitor=True should always be the first line in a
new Sub Main.
Change
to Monitor=False when
you "go production".
You then script one step at a
time, test-running with Menu:WWW --> Immediate (Hotkey =
F7).
At each step the monitor, which is built with objects from "Internet
Explorer", displays the result.
Click the "WriteToFile" button to
save the current page for further inspection.
For a faster way to
work, you can right-click on the displayed page area, then select "View Source"
from the popup menu.
Most commonly-used library
functions of
those we have added to
VBSCRIPT:
ExecuteWWW, a function used
for navigation and form submission.
XForm, an
object, consisting of the collection of elements in the first page form. Mostly
used for data entry into pages, but also for using the "document object
model" for scraping desired data out of a target page.
Scripting
Scripts
are plain text files written in the VBSCRIPT language. The language manual
is published at
http://msdn.microsoft.com/scripting
but that is a rather dry theoretical document.
We aim here to cover common PixieRobot by example.
Features and points of our implementation
The PixieRobot methods and
properties are supplied as an implicit object, ie functions such as ExecuteWWW and FileGetText become part
of the VBSCRIPT language for this environment.
If you wish to write in object syntax, that implicit
object is called "IW", so both of the following mean the
same:
Call IW.ExecuteWWW("http://www.pixieware.com")
Call
ExecuteWWW("http://www.pixieware.com")
Some VARs may wish to
script using the System.FileSystemObject. An implicit one of these named FS is
already provided, and you can use all of its methods and properties
directly. eg
Set drv =
GetDrive(GetDriveName(drvPath))
NOTE that you still
need to set and use sub-objects eg drv above
General VBSCRIPT note:
The For ... Next loop
requires that the closing keyword "Next" be on its own with no variable with
it. That can be tricky to get used to, especially with the less than
helpful error message it gives:
"1025, Expected
end of statement" eg:
'
'distribute multiple attachments
For i = 1 To AttachNumber
Call AttachMove(i, sDestination(i))
Next
'note this
must NOT be "Next i"
IW (Internet WWW Object): details of the scripting properties and methods
Grouped by purpose, all
keywords and file/path strings are case-insensitive.
Call ExecuteWWW( URL, [PostData], [EndOfTx] )
|
Part |
Description |
|
Url |
String: Address to navigate to, OR command "SUBMIT" |
|
PostData |
String: Optional data to submit in low-level formatlike"name=Michael&age= 37". |
|
EndOfTx |
String: Optional text to recognise as end of transmission. This is a bandwidth-saving device so when this text arrives in the page download, PixieRobot knows that it has received all that you need and can stop further downloading. Use distinctive text from near the end of the page. |
XForm(FieldNameOrIndex
)
[(ArrayIndex)].Value = Value
Call XForm(
FieldNameOrIndex)
.Click
Manipulate a
form field directly through an abbreviation of the HTML Document Object
Model
Note, this is equivalent to
WWW.Document.Forms(0).Elements(FieldNameOrIndex)[(ArrayIndex)].Value
= Value
but it is much easier to type. You may need the longer
"official" version if you have more
than one form on a page, or if the page
uses non-form-submission methods eg "remote scripting"
or
"field-by-field".
|
Part |
Description |
|
FieldNameOrIndex |
String or Integer: Field Name or Index to identify field to manipulate |
|
ArrayIndex |
Optional Integer, only needed when multiple fields have the same name |
|
Value |
Value for the field, usually string, but can be numeric, or for checkboxes, boolean =True/False |
Call OutputToFile( Data, Destination
)
Write string data as a disk file. Very useful for logging
results of scripting when developing scripts.
|
Part |
Description |
| Data | String to write to disk as data |
|
Destination |
String: full path of new file including file name |
stringData =
FileGetText(File_with_full_path_name)
Read contents
of a file into stringData. Useful for reading the contents of an
attachment to feed into other systems like databases. eg
stringData = FileGetText(PathAttachIn &
AttachFile(Index))
| Part | Description |
| MessageString | Message to log |
| Destination | String: full path of new file including file name |
LoggedMessage
String Property, returns the
previous logmessage sent to the logfile and monitor.
Call
LogMessage(Message)
Displays string
Message on the PixieRobot Monitor, as well as writing it to its
logbook.