Home > Language Reference > Web Functions > CaptureTableHTML

CaptureTableHTML

The CaptureTableHTML function captures the text of the specified range of cells in an HTML table within a Web page.

Usage

Used to retrieve data from colums or lines within a web table and insert data into an Excel file for instance. You can retrieve prices from ebay, retrieve job positions, capture phones from a yellow pages site, ... From the WinTask Editor window, select Start/Capture wizard menu to generate automatically the CaptureTableHTML syntax . A step by step capture process is available at Capturing Data in a Web Page.

Video: How to use CaptureTableHTML WinTask function for capturing a table displayed on a web page. The video gives too a trick for converting CONTENT into a variable.

Syntax

ret=CaptureTableHTML(<html_descriptor>, <range_descriptor>, tabcell$())

Parameters

<html_descriptor>, string, HTML descriptor of the HTML table element to capture. Use Capture wizard to generate the correct HTML descriptor. Only HTML descriptors using CONTENT keyword are valid for the CaptureTableHTML function.

<range_descriptor>, string, the range of cells to capture, such as "R4C2:R4C6" for the row 4 of the table and columns 2 to 6, or "R2C2:R5C2" for the column 2 of the table and rows 2 to 5.

tabcell$(), array of strings, captured cells. The array must be declared at the beginning of the script using Dim. The inner text of the cells specified in <range_descriptor> are written to tabcell$(), beginning with index 0. If the array is smaller than the range, only the number of cells which fit in the array are written.

Return value

Ret, optional numeric return code. If the function succeeds, the return value is the number of captured cells. If the function fails, the return value is a nonzero value (see Web Functions Error Codes).

Remarks

CaptureTableHTML does not include any synchronization; a UsePage must be used before to be sure that the table element to capture is ready.

If the table contains links to other urls, use ExtractLink function to extract all the urls listed in the table. And then you can use Navigate function to go to each url of the table.

See also

CaptureHTML 
GetHTMLEditText 
ExtractLink

Examples

dim tabcell$(50)
StartBrowser("IE","http://www.wintask.com/demos/data.htm")
UsePage("Capture Data from a Web Table")
ret = CaptureTableHTML("TABLE[CONTENT='Name']", "R1C1:R6C1", tabcell$())
msgbox("First name captured is the column title: "+tabcell$(0))
msgbox("First true name captured is: "+tabcell$(1))
msgbox("Second name captured is: "+tabcell$(2))
CloseBrowser()


dim tabcell$(50)
StartBrowser("FF","http://www.wintask.com/demos/data.htm")
UsePage("Capture Data from a Web Table")
ret = CaptureTableHTML("TABLE[CONTENT='Name']", "R1C1:R6C1", tabcell$())
msgbox("First name captured is the column title: "+tabcell$(0))
msgbox("First true name captured is: "+tabcell$(1))
msgbox("Second name captured is: "+tabcell$(2))
CloseBrowser()


dim tabcell$(50)
StartBrowser("FF","http://www.wintask.com/demos/data.htm")
UsePage("Capture Data from a Web Table")
ret = CaptureTableHTML("TABLE[CONTENT='Name']", "R1C1:R6C1", tabcell$())
msgbox("First name captured is the column title: "+tabcell$(0))
msgbox("First true name captured is: "+tabcell$(1))
msgbox("Second name captured is: "+tabcell$(2))
CloseBrowser()