Home > Mobile >  Can I get LONGITUDE AND LATITUDE from translate3d() - CSS? using Seleniun or beatifulsoup in python
Can I get LONGITUDE AND LATITUDE from translate3d() - CSS? using Seleniun or beatifulsoup in python

Time:01-25

I'm beginning on Webscraping and I have this link as example:

https://www.remax.pe/web/search/property/propiedad-otros-en-venta-los-olivos-lima-lima-1029168/

In this web there is a map, when I inspected in code html, I looked:

<img src="https://sfo3.digitaloceanspaces.com/media-remax-peru/static/web/img/marker.svg"  alt="Marker" tabindex="0" role="button" style="margin-left: -35px; margin-top: -45px; width: 70px; height: 90px; transform: translate3d(676px, 360px, 0px); z-index: 360;">

I searched at internet for get latitude and longitude using webscrapping with selenium or BS or any method.

I need latitude and longitude or any method for transform above code.

Can someone help me please,

Thanks in advance.

I found information on internet that said translate3d is used fo animations but I'm not sure if it's possible get latitud and longitud or this web not contain this two data so is impossible get latitude and longitude.

Please if someone can review this link and tell me if it's possible get latitude and longitude.

CodePudding user response:

You can obtain lat, long of the marker by parsing one of the <script> tags. One of <script>s has:

<script>
...

  var map = L.map('map_property').setView([-11.9422613, -77.0732493], zoom);
  
  var greenIcon = L.icon({
      iconUrl: 'https://sfo3.digitaloceanspaces.com/media-remax-peru/static/web/img/marker.svg',
      iconSize: [70, 90],
  });
  
  L.marker([-11.9422613, -77.0732493], {icon: greenIcon}).addTo(map).bindPopup(content);
  
...
</script>

For this case you can use the following code in python:

import requests
from bs4 import BeautifulSoup
import re


url = "https://www.remax.pe/web/search/property/propiedad-otros-en-venta-los-olivos-lima-lima-1029168"
html_text = requests.get(url).text
soup = BeautifulSoup(html_text, "html.parser")
for s in soup.find_all("script"):
    if "L.marker" in s.text:
        lat, long= re.match(r".*L\.marker\(\[([-,0-9\. ]*)", s.text, re.DOTALL).group(1).split(",")
        print("lat, long: ")
        print(lat, long)
  • Related