Files
maps-saas/scratch/test_google_preview.js
T
2026-04-16 04:13:55 +03:00

49 lines
1.9 KiB
JavaScript

const https = require('https');
async function testPlacePreview(lat, lng) {
// This is an internal-ish URL that sometimes returns cleaner data or direct names
const url = `https://www.google.com/maps/preview/place/${lat},${lng}`;
console.log(`Testing Preview URL: ${url}`);
return new Promise((resolve, reject) => {
const options = {
headers: {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1',
'Accept-Language': 'ar,en;q=0.9'
}
};
https.get(url, options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => {
// Search for the name in common patterns
// Google often returns a JSON-like structure here
// Try to find any quoted strings that look like "Name"
const nameRegex = /\[null,null,"([^"]+)",\[/i;
const match = body.match(nameRegex);
if (match) {
console.log(`\n🎉 POSSIBLE NAME FOUND: ${match[1]}`);
} else {
console.log('\n❌ No name found in preview response.');
// Check if there's any Arabic text at all
const arabicMatch = body.match(/[\u0600-\u06FF\s]+/g);
if (arabicMatch && arabicMatch.some(s => s.length > 5)) {
console.log('Found some Arabic text, but not isolated as a name.');
}
}
// console.log(body.substring(0, 5000));
resolve(null);
});
}).on('error', (err) => {
reject(err);
});
});
}
// Test with King Hussein Business Park
testPlacePreview(31.9822, 35.8453);