Nexchan commited on
Commit
9374051
·
verified ·
1 Parent(s): 939ea74

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +31 -0
index.js CHANGED
@@ -63,6 +63,37 @@ function getRandomUserAgent() {
63
  return userAgents[randomIndex];
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  const generateRandomIP = () => {
67
  const octet = () => Math.floor(Math.random() * 256);
68
  return `${octet()}.${octet()}.${octet()}.${octet()}`;
 
63
  return userAgents[randomIndex];
64
  }
65
 
66
+ app.get('/puppet', async (req, res) => {
67
+ const url = req.query.url;
68
+ if (!url) {
69
+ return res.status(400).send('URL query parameter is required');
70
+ }
71
+ try {
72
+ const browser = await puppeteer.launch({
73
+ headless: true,
74
+ args: ['--no-sandbox', '--disable-setuid-sandbox']
75
+ });
76
+ const page = await browser.newPage();
77
+ await page.setUserAgent(
78
+ 'Mozilla/5.0 (Linux; Android 10; SM-G965U Build/QP1A.190711.020; wv) ' +
79
+ 'AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.141 ' +
80
+ 'Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/420.0.0.32.61;]'
81
+ );
82
+ await page.setExtraHTTPHeaders({
83
+ 'Accept-Language': 'en-US,en;q=0.9',
84
+ 'Accept-Encoding': 'gzip, deflate, br',
85
+ 'Connection': 'keep-alive'
86
+ });
87
+ await page.goto(url, { waitUntil: 'networkidle2' });
88
+ const htmlContent = await page.content();
89
+ await browser.close();
90
+ res.send(htmlContent);
91
+ } catch (error) {
92
+ console.error('Error fetching HTML:', error);
93
+ res.status(500).send('Error fetching HTML content');
94
+ }
95
+ });
96
+
97
  const generateRandomIP = () => {
98
  const octet = () => Math.floor(Math.random() * 256);
99
  return `${octet()}.${octet()}.${octet()}.${octet()}`;