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

55 lines
2.3 KiB
JavaScript

const https = require('https');
async function testDeepScrape(lat, lng) {
const url = `https://www.google.com/maps/search/${lat},${lng}`;
console.log(`Deep Testing URL: ${url}`);
return new Promise((resolve, reject) => {
const options = {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'Accept-Language': 'ar,en;q=0.9',
'Cookie': 'NID=511=...' // Sometimes needed for better results
}
};
https.get(url, options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => {
console.log(`Page size: ${Math.round(body.length / 1024)} KB`);
// 1. Try to find window.APP_INITIALIZATION_STATE
const initStateMatch = body.match(/window\.APP_INITIALIZATION_STATE=([^;]+);/);
if (initStateMatch) {
const state = initStateMatch[1];
console.log('✅ Found APP_INITIALIZATION_STATE!');
// Look for Arabic strings in this blob
const arabicStrings = state.match(/[\u0600-\u06FF\s]{5,}/g);
if (arabicStrings) {
console.log('\n--- Arabic Strings found in State ---');
// Take the first few relevant-looking once
const candidates = [...new Set(arabicStrings)].slice(0, 10);
candidates.forEach(s => console.log(`- ${s.trim()}`));
}
} else {
console.log('❌ APP_INITIALIZATION_STATE not found.');
}
// 2. Try searching for "مجمع" or other POI keywords in the whole body
const poiKeywords = ['مجمع', 'بنك', 'مطعم', 'شركة', 'مكاتب'];
const foundKeywords = poiKeywords.filter(kw => body.includes(kw));
console.log('\nKeywords found in HTML:', foundKeywords.join(', ') || 'None');
resolve(null);
});
}).on('error', (err) => {
reject(err);
});
});
}
// Test with coordinates
testDeepScrape(31.9822, 35.8453);