Sie sind auf Seite 1von 21

Advanced Commands

Advanced Commands

After visually recording the main parts of the macro, enhance and fine-tune the macro by editing it.
All macros are simple text files File structure and commands fully documented

Macro in a Notepad File:

Editing Macros:
The recorded macro is stored in an easy to read text file (file ending: ".iim") which can be easily edited. To edit a macro go to edit tab present on the left hand side of the browser, next to play and record and press edit macro button. The default editor for editing Internet Macros is "Windows Notepad" (notepad.exe). You can use another editor by changing the default editor in EDIT tab > click OPTIONS > PATHS tab. If the macro has the name mymacro", the corresponding text file is called mymacro.iim".

Editing Macros Screenshot:

TOP 5 reasons to edit a macro

Edit typos made during recording


Insert Variables

Insert tags for response time measurements


Replace Session IDs with *

Copy & Paste several macros together or split macros in parts.

Session IDs
The link of some web sites change each time you visit them. This is because they create links with a "session id" which is different each time you log in. Solution 1: Try a different ClickMode Solution 2: Edit the macro manually after you recorded it and replace the ID (or any other changing part of the string) with "*". Example: The command line:
TAG POS=1 TYPE=AREA ATTR=HREF:https://overture.com/s/index.jhtml;$sessionid$ tzut78ZUZTIU67$&%

can be written as:


TAG POS=1 TYPE=AREA ATTR=HREF:*index.jhtml*

Two kinds of Variables:

Built-in variables
These variables are used to define certain properties of the macro behavior For example the macro timeout value SET !TIMEOUT 33.

User-defined Variables
These variables are created at run time by the command line "var_MYVAR <value>". For Example -var_ITEM 15 creates the variable {{ITEM}} and gives it the value 15. These variables can be part of ANYTHING inside the macro. In addition to routine tasks of opening and saving web pages, macros can be used for more complicated tasks. For example, extracting data from one website and inserting it into another.

Built-in Variables
SET !TIMEOUT 33
Defines new timeout value

SET !ERRORCONTINUE (YES/NO)


Tells IM to ignore errors and continue

SET !REPLAYSPEED (FAST/MEDIUM/SLOW)


SET !FILELOG c:\mylog.txt
Sets a specific log file name for the current macro

SET !EXTRACTADD {{!URLCURRENT}}


Contains the current page URL {{}} are used when the value of the variable is used

See user manual for a list of all built-in variables

Getting Data to a website

Submitting Data to Websites:


You can submit different information to the same Web page using Internet Macro. The data source can be in two different formats:
Either a text file with a list of variables and their values (ini file style) A comma separated text file (CSV format) which can be generated by Microsoft Excel and many other applications. The List of variables" format is recommend if you have many different variables (for example detailed address data or test of one user). The CSV format is most appropriate for use with a few variables with many different values (for example a long list of user accounts that you want to submit to a website).

You can link to any CSV or List of variable file by using the statement in the macro: CMDLINE !DATASOURCE mydata.txt

CSV and Variable Files


A CSV file looks like this:
FIRST NAME" , LAST NAME" , AGE Andrew", Smith", 23" John, Rafols, 39 Ann, Schwarz, 30

Variables in the macro:{{!COL1}}, {{!COL2}}, {{!COL3}}

A List of variables file looks like this:


[iOpus] FirstName=Andrew LastName=Smith Age=23

Variables in the macro: {{FirstName}}, {{LastName}}, {{Age}}

Demo: Submit Data to Website

Take a list of ISBN numbers from a file and search for them at Amazon.com
0970436300 0471430218 0471201006 0471232815 0131421891

Take a list of keywords and search for them on Google.com

Getting Data from web pages

Getting data from the Web Page


In general, getting data from websites is more complicated than submitting data, as there any many forms in which the data is made available. Internet Macros offers commands for each situation: Save web page Downloading file PRINT EXTRACT command More specialized commands:
Save Target As, Save Picture As Events

Web Data Extraction

TAG. EXTRACT=

Extracting Data:

Internet Macros can extract data from Web sites. Open the site of your interest and start recording. Click on the EXTRACT DATA button while in recording mode to bring up the extraction wizard. The EXTRACT button is only available in the iMacros Browser but not in the IE Plug-In.

Defining which Data to Extract:

Open the Extraction Wizard.

In the browser window select the text that you want to extract.
Click the "Suggest" Button.

Click TEST to test run the extraction.


If you are satisfied with the result, click ADD to add the EXTRACT statement to the macro. If you extract a complete table, the table data is automatically converted into comma-separated data

Data Extraction Wizard

How to Store Extracted Information


There are three ways to save extracted data: Built-in SAVEAS feature:
You can use the SAVEAS TYPE=EXTRACT command inside a macro. If several EXTRACT commands are used within one macro, the content is appended to the file.

Reuse in macro using the {{!EXTRACT}} variable Saving the data via the Internet Macros Scripting Interface:
When you run the macro from a script you can return the data to the script and save it with whatever method or format you prefer. For example, you can save it to a text file or even directly to a database.

Demo: Extract Data from Website

Create a price comparison engine: Take a list of ISBN numbers from a file and search for them at Amazon.com. Then save them in a CSV file with two columns (1st column: ISBN number, 2nd column: Price in US$)
0970436300 0471430218 0471201006 0471232815 0131421891

Das könnte Ihnen auch gefallen