48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
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);
|