| Products | Purchase | Support | Download | News | About |
|
|
Support - Script Examples |
|||
|
Screen Scraping Project: A host application displays formatted data on a specified keyword, for example, an account number, user ID, or filename. This data needs to be retrieved from the screen and either processed within the script, or passed on to a different PC-based application. Algorithm: The host application defines the sequence of screens and keystrokes to advance from one to the next. The script uses these to proceed from a known starting point such as the login banner to the desired host screen where the data can be retrieved. This part is much like the login script example, waiting for a prompt, and sending the command to go to the next screen. When the host screen with the desired data is displayed, a script function is used to retrieve the data from known coordinates on the screen and it is stored to a string variable or table. String functions and commands can then be used to validate or process the data. Product used in this example: DynaComm Connectivity Series® 9. (release 9.0.0.0) Relevant Commands and Functions:
SCREEN ( ) — retrieves a line of screen data at the position specified See Also:
PARSE — Locates a substring, storing the preceding and succeeding characters to string variables A Brief Example: Below is a picture of the screen we wish to scrape:
In this example, note the use of commas to include multiple commands on a line, and the use of the backslash character to continue a command on a second line.
SHOW
This example retrieves information on a particular file on the FutureSoft BBS. The first part of the script handles the process of connecting to the BBS assuming a SES file is created, and getting to the screen with the desired information. This essentially involves waiting for the expected prompt and sending the appropriate keystrokes to move within the host application. This example uses the FutureSoft BBS since it is a host application publicly available. Once we are at the correct screen, several fields of data are retrieved using the SCREEN( ) function and stored to string variables. The TRIM( ) function is used to remove trailing space characters from the strings. On this example screen, the host presents the file size followed by the word “bytes”. We want to retrieve the numeric value, which can be a variable number of characters, but not keep the word “bytes” since we want to eventually use the filesize as an integer. To do this, we screen scrape the whole field, use the POS( ) function to find the location of the word “bytes” in the string, and use the SUBSTR( ) function to keep only the characters preceding it. The PARSE command could also have been used to accomplish this step. In the final part of this example, we create a structured table to store the data scraped from the screen. The TABLE DEFINE line is used to define the table structure, including the number of fields and their lengths. This also creates a record buffer variable, @R0 in this case, which has the same field definitions. Variable assignment is used to load the values of the respective fields into the record buffer, and it is written to the table using the RECORD WRITE command. The TABLE SAVE command is used to save it to a file so it can be viewed later. Usually, more than one record would be written to the table, in which case a loop would be added and the TABLE DEFINE command would be moved to ensure the table is initialized only once. See the Data Tables example for further illustration on the use of tables. Further development:
$field1 = SCREEN(10,10,10) |
|||
![]() |
Purchase | Contact | Privacy Policy | Terms of Use | Sitemap | Blog |
© 2010 FutureSoft, Inc. All Rights Reserved
|
||||||
|
DynaComm i:filter |
Internet Filtering |
Employee Internet Monitoring |
Managing Internet Access |
Web Filtering |
Internet Monitoring |
DCS Terminal Emulation | TN 3270 | ProComm Plus Replacement | Windows Terminal Emulation | TN 5250 | DynaComm Connectivity Series | MultiView |
||||||