2026-04-16-2
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
const https = require('https');
|
||||
|
||||
async function testDDGVerify(lat, lng) {
|
||||
// DuckDuckGo search for coordinates often yields the POI name in the title or a snippet
|
||||
const url = `https://duckduckgo.com/html/?q=${lat},${lng}`;
|
||||
console.log(`Checking DuckDuckGo for: ${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'
|
||||
}
|
||||
};
|
||||
|
||||
https.get(url, options, (res) => {
|
||||
let body = '';
|
||||
res.on('data', chunk => body += chunk);
|
||||
res.on('end', () => {
|
||||
// Look for the title which usually contains the location name
|
||||
const titleMatch = body.match(/<title>([^<]+)<\/title>/);
|
||||
if (titleMatch) {
|
||||
const title = titleMatch[1];
|
||||
console.log(`\n🎉 EXTRACTED TITLE: ${title}`);
|
||||
// Usually title is "Names - DuckDuckGo"
|
||||
const cleanedName = title.split(' at DuckDuckGo')[0].split(' - DuckDuckGo')[0];
|
||||
console.log(`Cleaned Name: ${cleanedName}`);
|
||||
} else {
|
||||
console.log('No title found in DDG response.');
|
||||
}
|
||||
|
||||
// Also search for Arabic POI names in the snippet
|
||||
const arabicStrings = body.match(/[\u0600-\u06FF\s]{5,}/g);
|
||||
if (arabicStrings) {
|
||||
console.log('\nPotential Arabic matches from DDG:');
|
||||
[...new Set(arabicStrings)].slice(0, 5).forEach(s => console.log(`- ${s.trim()}`));
|
||||
}
|
||||
|
||||
resolve(null);
|
||||
});
|
||||
}).on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test with Coordinates
|
||||
testDDGVerify(31.9822, 35.8453);
|
||||
@@ -0,0 +1,54 @@
|
||||
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);
|
||||
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user