在Python中从网页中提取Lat Lon值

时间:2012-07-17 07:06:01

标签: python html

我对Python比较陌生,除了lat lon组末尾的“fillColor”值之外,我还试图为每个集合提取lat lon值。我只需要一个数组中的lat lon值,然后是另一个将特定颜色分配给lat lon组的变量。每组lat lon都是多边形,填充颜色是它的相应颜色。我有BeautifulSoup并且没有运气搜索正则表达式操作。以下是网页源代码的示例,其中一些LatLng值是为了长度而剪切的。 var gc#从新的多边形集开始,接近结尾你可以看到fillColor和相应的RGB代码:

var gc2 = new google.maps.LatLng(45.1323599532, - 112.897926051);

var gcpoly2 = new google.maps.Polygon({
    paths: [new google.maps.LatLng(45.802586, - 112.965677), new google.maps.LatLng(45.802047, - 112.928468), new google.maps.LatLng(44.781129, - 111.781812), new google.maps.LatLng(44.708849, - 111.781713), new google.maps.LatLng(44.709214, - 111.472921), new google.maps.LatLng(44.700221, - 111.490228), new google.maps.LatLng(45.063519, - 113.485278), new google.maps.LatLng(45.093033, - 113.520134), new google.maps.LatLng(45.115225, - 113.513342), new google.maps.LatLng(45.123894, - 113.571681), new google.maps.LatLng(45.88141, - 113.100177), new google.maps.LatLng(45.853827, - 113.082638), new google.maps.LatLng(45.802586, - 112.965677)],
    strokeColor: "#FFFF00",
    strokeOpacity: 1,
    strokeWeight: 2,
    fillColor: "#FFFF00",
    fillOpacity: 0.4
});

google.maps.event.addListener(gcpoly2, "click", function () {
    contentString = "<div class='popover.right.arrow'><div class='popover-inner'><div class='popover-title' style='text-color:#FFFF00'>RESTRICTIONS</div><div class='popover-content'><a href='/mt/mt-beaverhead-county/'>Beaverhead County</a>, <a href='/mt/'>MT</a></div></div></div>";
    infowindow.setContent(contentString);
    infowindow.setPosition(gc2);
    infowindow.open(map2);
});
gcpoly2.setMap(map2);

var gc3 = new google.maps.LatLng(45.4223802114, - 107.489302039);

var gcpoly3 = new google.maps.Polygon({
    paths: [new google.maps.LatLng(44.996481, - 107.046092), new google.maps.LatLng(44.999458, - 108.249345), new google.maps.LatLng(45.00818, - 108.258603), new google.maps.LatLng(45.042234, - 108.244399), new google.maps.LatLng(45.047429, - 108.220828), new google.maps.LatLng(45.063107, - 108.239248), new google.maps.LatLng(45.094538, - 108.217042), new google.maps.LatLng(45.100302, - 108.188627), new google.maps.LatLng(45.676491, - 106.727488), new google.maps.LatLng(45.351684, - 106.729604), new google.maps.LatLng(45.352883, - 106.768606), new google.maps.LatLng(45.179679, - 106.768014), new google.maps.LatLng(45.179792, - 106.263682), new google.maps.LatLng(44.993788, - 106.263586), new google.maps.LatLng(44.996481, - 107.046092)],
    strokeColor: "#FFFF00",
    strokeOpacity: 1,
    strokeWeight: 2,
    fillColor: "#FFFF00",
    fillOpacity: 0.4
});

google.maps.event.addListener(gcpoly3, "click", function () {
    contentString = "<div class='popover.right.arrow'><div class='popover-inner'><div class='popover-title' style='text-color:#FFFF00'>RESTRICTIONS</div><div class='popover-content'><a href='/mt/mt-bighorn-county/'>Bighorn County</a>, <a href='/mt/'>MT</a></div></div></div>";
    infowindow.setContent(contentString);
    infowindow.setPosition(gc3);
    infowindow.open(map2);
});

感谢您的帮助!

0 个答案:

没有答案