Compare commits
1 Commits
rename
...
lat-lng-sc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0b4bc7879 |
27
app/helpers/scraping.js
Normal file
27
app/helpers/scraping.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
let fetch = require("node-fetch");
|
||||||
|
|
||||||
|
const getRealEstateGeolocation = async (url) => {
|
||||||
|
let response = await fetch(url);
|
||||||
|
const body = await response.text();
|
||||||
|
let lat, long;
|
||||||
|
const googleMapRegex = new RegExp(/google.maps.LatLng\((.*?)\)/g);
|
||||||
|
const googleMapString = body.match(googleMapRegex);
|
||||||
|
if (googleMapString && googleMapString.length) {
|
||||||
|
const latLongRegex = new RegExp(/\((.*?)\)/g);
|
||||||
|
let latLongString = googleMapString[0].match(latLongRegex);
|
||||||
|
if (latLongString && latLongString.length) {
|
||||||
|
latLongString = latLongString[0].trim();
|
||||||
|
latLongString = latLongString.substr(1, latLongString.length - 2);
|
||||||
|
const latLongArray = latLongString.split(",");
|
||||||
|
if (latLongArray.length) {
|
||||||
|
lat = latLongArray[0];
|
||||||
|
long = latLongArray[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { lat, long };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getRealEstateGeolocation
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user