getContent
codebolt.browser.getContent(): Promise<GetContentResponse>
Retrieves the content of the current page.
Response Structure
The method returns a Promise that resolves to a GetContentResponse
object with the following properties:
Response Properties:
type
: Always "getContentResponse"content
: Optional string containing the page contenthtml
: Optional string containing the HTML contenttext
: Optional string containing the text contentsuccess
: Optional boolean indicating if the operation was successfulmessage
: Optional string with additional informationerror
: Optional string containing error details if the operation failedmessageId
: Optional unique identifier for the messagethreadId
: Optional thread identifier
Example
// Navigate to the page
await codebolt.browser.goToPage("https://example.com");
// Wait for page to load
await new Promise(resolve => setTimeout(resolve, 2000));
// Retrieve the content of the current page
const contentResult = await codebolt.browser.getContent();
console.log('✅ Content retrieved:', {
success: contentResult.success,
contentLength: contentResult.content ? contentResult.content.length : 0,
hasHtml: !!contentResult.html,
hasText: !!contentResult.text
});
// Access the actual content
if (contentResult.success && contentResult.content) {
console.log('Page content:', contentResult.content);
// Process the content as needed
}