如何使用硒从网站获取经纬度(地图图标)?

How to get the latitude and longitude (map icon) from a website using selenium?

我正在尝试抓取网站以查找该地点的纬度和经度。地图图标可在网站上找到。单击时地图图标重定向到 justdial 地图。网站中的图标为

地图图标的检查元素是

<a title="Map for JICE Academy For Excellence Pvt Ltd, Vijayanagar" href="javascript:;" onclick="view_map('080PXX80.XX80.121102122047.B3M5', 'map', 'Bangalore');
                                                        _ct('map', 'dtpg');">
                                        <span class="ico-mapicn"></span>
                                        <span class="wrtrvtxt">Map</span>
</a>

在我看来 view_map 是一个函数,它的第一个参数是坐标。我使用

抓取了这个
url = "https://www.justdial.com/Bangalore/Race-Coaching-Institute-Pvt-Ltd-Hosur-Road/080PXX80-XX80-170420162628-Z6C1_BZDET?xid=QmFuZ2Fsb3JlIEJhbmsgRXhhbSBUdXRvcmlhbHM="
wd = webdriver.Chrome(chrome_path)
wd.get(url)
ele = wd.find_element_by_xpath('//a[@class="mapicn"]')
print(ele.get_attribute('onclick'))

但我无法弄清楚它是什么格式。有没有其他方法可以获得那个地方的准确纬度和对数?

页面中没有经纬度,要获取可以模拟post请求到https://..../functions/maps.php或者拦截XMLHttpRequest

url = "https://......."
wd = webdriver.Chrome()
wd.get(url)
wd.execute_script('''
(function(open) {
    window.XMLHttpRequest.prototype.open = function() {
        this.addEventListener("readystatechange", function() {
            if(this.readyState == 4 && this.responseURL.indexOf('maps.php') > -1){
                window.latlong = this.responseText
            }
        }, false);
        open.apply(this, arguments);
    };
})(window.XMLHttpRequest.prototype.open);
''')

wd.find_element_by_xpath('//a[@class="mapicn"]').click()

latlong = wd.execute_async_script('var theData = arguments[0]; theData(latlong)')
print(latlong)
# {"lil":"12.889135400000","lon":"77.639586800000"}