feat: load website html

This commit is contained in:
karishmas6
2024-04-21 19:51:35 +05:30
parent ed5dd602ac
commit 2c1a9a4cd0

19
scraper/src/load.js Normal file
View File

@@ -0,0 +1,19 @@
import { PlaywrightCrawler, Configuration } from "crawlee";
async function loadWebsite(url) {
let htmlContent = '';
const crawler = new PlaywrightCrawler({
requestHandler: async ({ page }) => {
await page.goto(url);
htmlContent = await page.content();
}
},
new Configuration({
persistStorage: false,
}));
await crawler.run([url]);
return htmlContent;
}
export default loadWebsite;