Spaces:
Running
Running
| const fs = require('fs'); | |
| const path = require('path'); | |
| const cheerio = require('cheerio'); | |
| const urls = [ | |
| { name: 'tours', url: 'https://www.thewallthathealsreynolds.org/tours.html' }, | |
| { name: 'escort', url: 'https://www.thewallthathealsreynolds.org/escort.html' }, | |
| { name: 'honor', url: 'https://www.thewallthathealsreynolds.org/honor.html' }, | |
| { name: 'contact', url: 'https://www.thewallthathealsreynolds.org/contact.html' } | |
| ]; | |
| const { execSync } = require('child_process'); | |
| async function scrapeForms() { | |
| for (const item of urls) { | |
| console.log(`Fetching ${item.url}...`); | |
| try { | |
| const html = execSync(`curl -s -k "${item.url}"`).toString(); | |
| const $ = cheerio.load(html); | |
| // Find the form container | |
| let formHtml = ''; | |
| const formContainer = $('.contact-form'); | |
| if (formContainer.length > 0) { | |
| formHtml = $.html(formContainer); | |
| } else { | |
| const justForm = $('form[data-validate]'); | |
| if (justForm.length > 0) { | |
| formHtml = $.html(justForm); | |
| } else { | |
| const fallback = $('form'); | |
| if (fallback.length > 0) { | |
| formHtml = $.html(fallback.first()); | |
| } | |
| } | |
| } | |
| if (formHtml) { | |
| const finalHtml = `<!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>${item.name.charAt(0).toUpperCase() + item.name.slice(1)} Form</title> | |
| <style> | |
| body { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| background-color: transparent; | |
| margin: 0; | |
| padding: 20px; | |
| color: #333; | |
| } | |
| .contact-form { | |
| max-width: 600px; | |
| margin: 0 auto; | |
| background: #fff; | |
| padding: 30px; | |
| border-radius: 8px; | |
| box-shadow: 0 4px 6px rgba(0,0,0,0.1); | |
| } | |
| .form-group { | |
| margin-bottom: 20px; | |
| } | |
| label { | |
| display: block; | |
| margin-bottom: 8px; | |
| font-weight: 500; | |
| color: #1a365d; | |
| } | |
| input[type="text"], | |
| input[type="email"], | |
| input[type="tel"], | |
| select, | |
| textarea { | |
| width: 100%; | |
| padding: 10px; | |
| border: 1px solid #ccc; | |
| border-radius: 4px; | |
| font-size: 16px; | |
| box-sizing: border-box; | |
| } | |
| button[type="submit"], input[type="submit"] { | |
| background-color: #1a365d; | |
| color: white; | |
| padding: 12px 24px; | |
| border: none; | |
| border-radius: 4px; | |
| font-size: 16px; | |
| cursor: pointer; | |
| width: 100%; | |
| transition: background-color 0.2s; | |
| } | |
| button[type="submit"]:hover, input[type="submit"]:hover { | |
| background-color: #2c5282; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| ${formHtml.replace(/action="[^"]*"/g, '').replace(/method="[^"]*"/g, '')} | |
| <!-- Integration Script to automatically wire this form up to the Hugging Face API --> | |
| <script src="/live-site-integration.js"></script> | |
| </body> | |
| </html>`; | |
| const outputPath = path.join(__dirname, 'public', `${item.name}.html`); | |
| fs.writeFileSync(outputPath, finalHtml); | |
| console.log(`Saved form to ${outputPath}`); | |
| } else { | |
| console.log(`No form found on ${item.url}`); | |
| } | |
| } catch (e) { | |
| console.error(`Failed to fetch ${item.url}:`, e); | |
| } | |
| } | |
| } | |
| scrapeForms(); | |