zlacker

[parent] [thread] 0 comments
1. mckrav+(OP)[view] [source] 2023-03-02 18:17:40
I have just decided to give it another try on a very straightforward thing. I have asked it to get me a Rust function that uses a headless browser to get the HTML of a fully loaded webpage.

ChatGPT:

let screenshot = tab.capture_screenshot(ScreenshotFormat::PNG, None, true).await?;

let html = String::from_utf8(screenshot).unwrap();

>[...] Once the page is fully loaded, the function captures a screenshot of the page using tab.capture_screenshot(), converts the screenshot to a string using String::from_utf8(), and then returns the string as the HTML content of the page.

Of course, it admits to the mistake (sort of, it still does not get):

> You are correct, taking a screenshot and converting it to text may not always be the best approach to extract the HTML content from a webpage.

It's hilarious.

[go to top]