Home > Language Reference > Web Functions > GetPageSource$

GetPageSource$

The GetPageSource$ function retrieves the source code of the specified web page.

Usage

It gives the same results as the View/Source option on the context menu after right-click somewhere in the web page.

Video: If WinTask x64 Capture tool is not enough to capture what you want on a Web page, you can still retrieve the page source using GetPageSource$ function and extract the needed part. This video demonstrates how to proceed using GetPageSource$ExtractBetween$ and SplitIntoArray WinTask x64 functions.

Syntax

var$=GetPageSource$()

Parameter

None.

Return value

var$, string, source code. If the function fails, the return value is an empty string (an empty string is ""). The maximum size for var$ is 16 Mb.

Remarks

Before calling this function, you must ensure that the page is fully loaded with a UsePage statement.

GetPageSource$ calls directly the Innertext property of the browser. Due to the way notepad displays this same information, there can be some differences between what you see in notepad using View/Source option and the result of GetPageSource$ function.

See also

GetFrameSource$

Examples

'On WinTask Web site, we display the source code of the main page:
StartBrowser("IE","www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
a$=GetPageSource$()
CloseBrowser()
msgbox(a$)

'On WinTask Web site loaded in Firefox, we display the source code of the main page:
StartBrowser("FF","www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
a$=GetPageSource$()
CloseBrowser()
msgbox(a$)


'On WinTask Web site loaded in Chrome, we display the source code of the main page:
StartBrowser("CH","www.wintask.com")
UsePage("Macro and Data Extraction with WinTask - the automation software for Windows and internet")
a$=GetPageSource$()
CloseBrowser()
msgbox(a$)