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 = ` ${item.name.charAt(0).toUpperCase() + item.name.slice(1)} Form ${formHtml.replace(/action="[^"]*"/g, '').replace(/method="[^"]*"/g, '')} `; 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();