forked from arpitm859/Road-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaps.js
31 lines (24 loc) · 887 Bytes
/
maps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const puppeteer = require('puppeteer');
async function getCoord(address){
var URL = "https://www.google.com/maps"
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(URL, {waitUntil:"networkidle2"});
await page.waitForSelector('#searchboxinput');
await page.type('#searchboxinput', address)
console.log("---------------Searching for :"+address);
await page.click('.searchbox-searchbutton-container');
await delay(10000);
const data = await page.url();
browser.close();
let arr = data.split('@')[1].split(',').slice(0, 2);
//console.log(arr);
return arr;
}
//getCoord("2/324, Jankipuram Vistar, Sitapur Road, Lucknow, Uttar Pradesh, India")
function delay(time){
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}
module.exports = getCoord;