feat: get html content
This commit is contained in:
@@ -143,7 +143,7 @@ export class RemoteBrowser {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.client.on('Page.screencastFrame', ({ data: base64, sessionId }) => {
|
this.client.on('Page.screencastFrame', ({ data: base64, sessionId }) => {
|
||||||
this.emitScreenshot(base64);
|
this.emitScreenshot(base64)
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
if (!this.client) {
|
if (!this.client) {
|
||||||
@@ -174,21 +174,22 @@ export class RemoteBrowser {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes and emits a single screenshot to the client side.
|
* Makes and emits a single screenshot to the client side.
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
public makeAndEmitScreenshot = async (): Promise<void> => {
|
public makeAndEmitScreenshot = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const screenshot = await this.currentPage?.screenshot();
|
const screenshot = await this.currentPage?.content();
|
||||||
if (screenshot) {
|
if (screenshot) {
|
||||||
this.emitScreenshot(screenshot.toString('base64'));
|
const base64Html = Buffer.from(screenshot).toString('base64');
|
||||||
|
this.emitScreenshot(base64Html);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const { message } = e as Error;
|
const { message } = e as Error;
|
||||||
logger.log('error', message);
|
logger.log('error', message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the active socket instance.
|
* Updates the active socket instance.
|
||||||
@@ -337,7 +338,7 @@ export class RemoteBrowser {
|
|||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
private emitScreenshot = (payload: any): void => {
|
private emitScreenshot = (payload: any): void => {
|
||||||
const dataWithMimeType = ('data:image/jpeg;base64,').concat(payload);
|
const dataWithMimeType = (',').concat(payload);
|
||||||
this.socket.emit('screencast', dataWithMimeType);
|
this.socket.emit('screencast', dataWithMimeType);
|
||||||
logger.log('debug', `Screenshot emitted`);
|
logger.log('debug', `Screenshot emitted`);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user