pythonselenium-webdriverweb-scrapingcoordinates

Coordinates of a location in a web page


I am trying to extract the coordinates e. g. longitude and latitude of the pointer on a map depicted on a static google maps image from a house listing.

Example: https://www.zoopla.co.uk/to-rent/details/69415984/?search_identifier=da040698b5509116df6fa28b403e3d616bd49cf9279d33fb5888d76863700cb5&weekly_featured=1&utm_content=featured_listing

Is it possible? There is also a static google maps image of the location attached below.

What is the best way to do this?

I've tried to find the location in the metadata, but there was none.

import exifread

def check_exif(image_path):
    with open(image_path, 'rb') as f:
        tags = exifread.process_file(f)
        if not tags:
            print("No EXIF metadata found.")
        else:
            print("EXIF metadata keys:", tags.keys())

check_exif("image.jpg")

enter image description here


Solution

  • Open map, get the page source and search for this regex:

    "latitude\\":(-?\d+\.\d+),\\"longitude\\":(-?\d+\.\d+)
    

    Extract numbers and you have your coordinates.

    Map view

    Same location in Google Maps

    Source code in Sublime Text I've changed the regex.