Home > Language Reference > Web Functions > CaptureHTML

CaptureHTML

The CaptureHTML function captures the text of the specified HTML element within a Web page.

Usage

Used to retrieve data from a Web page and paste into another application. From the WinTask x64 Editor window, select Start/Capture wizard menu to generate automatically the CaptureHTML syntax . For retrieving data organized in Table, use CaptureTableHTML. A step by step capture process is available at Capturing Data in a Web Page.

Video: How to capture a text displayed on a web page using WinTask x64 Spy tool and extracts a part of the captured text using ExtractBetween$ WinTask x64 function.

Syntax

ret=CaptureHTML(<html_descriptor>, var$)

Parameters

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

var$, string, captured text.

Return value

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

Remarks

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

Use GetHTMLEditText function for capturing the content of a web form field.

See also

CaptureTableHTML
GetHTMLEditText

Examples

StartBrowser("IE","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ret = CaptureHTML("P[CONTENT='Click']",var$)
Msgbox(var$)
CloseBrowser()

StartBrowser("FF","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ret = CaptureHTML("P[CONTENT='Click']",var$)
Msgbox(var$)
CloseBrowser()

StartBrowser("CH","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ret = CaptureHTML("P[CONTENT='Click']",var$)
Msgbox(var$)
CloseBrowser()