Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
How can I convert longitude and latitude to a country name?

After printing the long and the lat, I want it to print out the country name. Is there a way of using the long and lat to figure out the country and then print that out to the console at the end?

  const puppeteer = require("puppeteer"); 
  const url = "https://www.google.com/";
  

  async function StartScraping() {
    await puppeteer
      .launch({
        headless: false,
      })
      .then(async (browser) => {
        const page = await browser.newPage();
  
        await page.setViewport({
          width: 1800,
          height: 800,
        });
  
        page.on("response", async (response) => {
  
         
          if (response.url().includes("CoordinateFile")) 
          {
            const location = await response.text() 
            let intlong = location.indexOf("Coordinates:")
            const longlat = location.substring(intlong +12, intlong + 44)
            //split long lat here 
            
            var long = longlat.substring(0, longlat.indexOf(',') - 5);
            var lat = longlat.substring(longlat.indexOf(',') +1, (longlat.indexOf(',') + 7));
            console.log(`Longitude: ${long}`);
            console.log(`Latitude: ${lat}`);
           

          }
  
        });
  
        await page.goto(url, {
          waitUntil: "load",
          timeout: 0,
        });
      });
  }

  StartScraping();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!