Spaces:
Running
Running
const express = require('express'); | |
const puppeteer = require('puppeteer'); | |
const app = express(); | |
const targetUrl = 'https://chatgpt.com/'; | |
app.get('/', async (req, res) => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(targetUrl); | |
const html = await page.content(); | |
await browser.close(); | |
// Здесь вы можете модифицировать HTML-код, например, заменить URL-адреса | |
const newHtml = html.replace(new RegExp(targetUrl, 'g'), req.protocol + '://' + req.get('host')); | |
res.send(newHtml); | |
}); | |
const port = 7860; | |
app.listen(port, () => { | |
console.log(`Сервер запущен на порту ${port}`); | |
}); |