Neon-AI commited on
Commit
5d1e8b8
·
verified ·
1 Parent(s): 930fc38

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +21 -11
index.js CHANGED
@@ -3,37 +3,47 @@ const { chromium } = require('playwright');
3
  (async () => {
4
  const browser = await chromium.launch({
5
  headless: true,
6
- args: ['--no-sandbox', '--disable-setuid-sandbox']
7
  });
8
  const page = await browser.newPage();
9
 
10
  try {
 
 
 
 
11
  await page.goto('https://en.ephoto360.com/create-3d-colorful-paint-text-effect-online-801.html', {
12
  waitUntil: 'domcontentloaded',
13
- timeout: 60000
14
  });
15
 
16
- await page.waitForSelector('input[name="text[]"]', { timeout: 30000 });
17
  await page.fill('input[name="text[]"]', 'TEST TEXT');
18
 
19
- await page.click('input[type="submit"][value="GO"]');
20
 
21
- await page.waitForTimeout(30000); // longer wait for generation
22
 
23
  const imageUrl = await page.evaluate(() => {
24
- const imgs = [...document.querySelectorAll('img[src*="uploads"]')];
25
- return imgs.find(img =>
26
- img.src.includes('worigin') || img.src.includes('result')
27
- )?.src || null;
 
 
 
28
  });
29
 
30
  console.log('Generated image:', imageUrl || 'not found');
31
 
32
- if (!imageUrl) await page.screenshot({ path: 'debug.png', fullPage: true });
 
 
 
33
 
34
  } catch (err) {
35
  console.error('Error:', err.message);
36
- await page.screenshot({ path: 'error.png', fullPage: true });
37
  }
38
 
39
  await browser.close();
 
3
  (async () => {
4
  const browser = await chromium.launch({
5
  headless: true,
6
+ args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
7
  });
8
  const page = await browser.newPage();
9
 
10
  try {
11
+ await page.setExtraHTTPHeaders({
12
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36'
13
+ });
14
+
15
  await page.goto('https://en.ephoto360.com/create-3d-colorful-paint-text-effect-online-801.html', {
16
  waitUntil: 'domcontentloaded',
17
+ timeout: 90000
18
  });
19
 
20
+ await page.waitForSelector('input[name="text[]"]', { timeout: 40000 });
21
  await page.fill('input[name="text[]"]', 'TEST TEXT');
22
 
23
+ await page.click('input[value="GO"]');
24
 
25
+ await page.waitForTimeout(45000);
26
 
27
  const imageUrl = await page.evaluate(() => {
28
+ const imgs = document.querySelectorAll('img[src*="uploads"]');
29
+ for (const img of imgs) {
30
+ if (img.src.includes('worigin') || img.src.includes('result') || img.src.includes('w450')) {
31
+ return img.src;
32
+ }
33
+ }
34
+ return null;
35
  });
36
 
37
  console.log('Generated image:', imageUrl || 'not found');
38
 
39
+ if (!imageUrl) {
40
+ await page.screenshot({ path: 'debug.png', fullPage: true });
41
+ console.log('Screenshot saved: debug.png');
42
+ }
43
 
44
  } catch (err) {
45
  console.error('Error:', err.message);
46
+ try { await page.screenshot({ path: 'error.png', fullPage: true }); } catch {}
47
  }
48
 
49
  await browser.close();