import process from "node:process";
export const browserlessScrapeExample = (async () => {
try {
const res = await fetch(
`https://chrome.browserless.io/scrape?token=${process.env.browserlessKey}`,
{
method: "POST",
headers: {
"Cache-Control": "no-cache",
"Content-Type": "application/json",
},
body: JSON.stringify({
"url": "https://www.zaobao.com/realtime",
"elements": [{
"selector": "body",
}],
}),
},
);
const data = await res.json();
console.log(data);
return data.data[0].results[0].html;
} catch (err) {
console.log(err);
}
})();