简体   繁体   English

如何从动态地图上刮取地理坐标?

[英]How to scrape geographic coordinates from dynamic map?

A dynamic Google map is embedded on a web page, with a drag-gable marker. 动态Google地图嵌入在网页上,带有可拖动的标记。 This gives the location when the marker is dropped. 这给出了放置标记时的位置。 I am trying to scrape the latitude and longitude using python. 我正在尝试使用python刮擦经度和纬度。 I have tried the following code: 我尝试了以下代码:

import urllib
import re
url = urllib.urlopen("file:///C:/Users/Test.html").read()

i = 0

regex = '<p>Current Position: Latitude: (.+?) Longitude: (.+?)</p>'
pattern = re.compile(regex)

results = re.findall(pattern,url)

print results

This brings up the HTML for the latitude and longitude. 这将调出纬度和经度的HTML。 How do you retrieve the actual lat/long? 您如何获取实际的经/纬度?

you need to get the groups (captured with '(..)' in your regex) from your result: 您需要从结果中获取组(在正则表达式中用'(..)'捕获):

lat = results.groups(1)
long = results.groups(2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM