使用Ruby从网站上的地图中搜索坐标

时间:2015-10-20 12:10:25

标签: ruby web-scraping screen-scraping mechanize openstreetmap

我需要从仅在之后显示的网站中提取值 单击一个按钮。该值在源代码中可见 当我使用Firebug访问它但在结果中找不到它 of mechanize.get(url)。

我应该如何使用Ruby和Mechanize获取数据?

注意:我想要提取的值是OpenStreetMap地图的坐标。

HTML code:

<body>
        <div id="backgrounds_header"></div>
        <div id="global">
            <div id="header"></div>
            <ul id="menu"></ul>
            <div id="main">
                <div id="content">
                    <div id="tab_global">
                        <div id="tab_resultat_global">
                            <div id="tab_page">
                                <div id="recherche_zone_moins_plus"></div>
                                <divid="recherche_carbu_boutons_affichage"></div>
                                <form id="pagination" method="GET"action="/recherche/">
                                    <div style="padding-left: 10px;"></div>
                                    <table id="tab_resultat">
                                        <tbody>
                                            <tr></tr>
                                            <tr class="infos" style="display: none;">
                                                <td colspan="11">
                                                    <div class="infos"></div>
                                                    <div class="minimap">
                                                        <div class="indisponible" style="text-align: center; color: red; display: none; float: left;"></div>
                                                        <tr id="67480002" class="data charged"></tr>
                                                        <div class="actions" style="display:block; float: right"></div>
                                                        <div id="minimap67480002" class="olMap" style="height: 300px; width: 500px;">
                                                            <div id="OpenLayers_Map_2_OpenLayers_ViewPort" class="olMapViewport olControlDragPanActive olControlZoomBoxActive olControlPinchZoomActive olControlNavigationActive" style="position: relative; overflow: hidden; width: 100%; height: 100%;">

    <div id="OpenLayers_Map_2_OpenLayers_Container" style="position: absolute; z-index: 749; left: 0px; top: 0px;">
        <div id="OpenLayers_Layer_WMTS_23" class="olLayerDiv olLayerGrid" style="position: absolute; width: 100%; height: 100%; z-index: 100;" dir="ltr"></div>

<div id="OpenLayers_Layer_Vector_34" class="olLayerDiv" style="position: absolute; width: 100%; height: 100%; z-index: 330; left: 0px; top: 0px;" dir="ltr">

                            <svg id="OpenLayers_Layer_Vector_34_svgRoot" style="display: block;" width="500" height="300" viewBox="0 0 500 300">
                                <g id="OpenLayers_Layer_Vector_34_root" style="visibility: visible;" transform=""></g>
                            </svg>
                        </div>
                    </div>
                    <div id="OpenLayers_Control_Zoom_5" class="olControlZoom olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                    <div id="OpenLayers_Control_ArgParser_6" class="olControlArgParser olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                    <div id="OpenLayers_Control_Attribution_7" class="olControlAttribution olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                </div>
            </div>
            <input id="67480002_lat" type="hidden" value="48.8229151543"></input>
            <input id="67480002_lon" type="hidden" value="8.03104056977"></input>
        </div>
        <span class="clear"></span>
    </td>

</tr> <tr id="67960001" class="data clair charged show"></tr>

<tr class="infos" style="">

    <td colspan="11">
        <div class="infos"></div>
        <div class="minimap">
            <div class="indisponible" style="text-align: center; color: red; display: none; float: left;"></div>
            <div class="actions" style="display:block; float: right"></div>
            <div id="minimap67960001" class="olMap" style="height: 300px; width: 500px;">
                <div id="OpenLayers_Map_47_OpenLayers_ViewPort" class="olMapViewport olControlDragPanActive olControlZoomBoxActive olControlPinchZoomActive olControlNavigationActive" style="position: relative; overflow: hidden; width: 100%; height: 100%;">

    <div id="OpenLayers_Map_47_OpenLayers_Container" style="position: absolute; z-index: 749; left: 0px; top: 0px;">
        <div id="OpenLayers_Layer_WMTS_67" class="olLayerDiv olLayerGrid" style="position: absolute; width: 100%; height: 100%; z-index: 100;" dir="ltr"></div>

<div id="OpenLayers_Layer_Vector_78" class="olLayerDiv" style="position: absolute; width: 100%; height: 100%; z-index: 330; left: 0px; top: 0px;" dir="ltr"></div>

                    </div>
                    <div id="OpenLayers_Control_Zoom_50" class="olControlZoom olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                    <div id="OpenLayers_Control_ArgParser_51" class="olControlArgParser olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                    <div id="OpenLayers_Control_Attribution_52" class="olControlAttribution olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                </div>
            </div>
            <input id="67960001_lat" type="hidden" value="48.5392769"></input>
            <input id="67960001_lon" type="hidden" value="7.6491786"></input>
        </div>
        <span class="clear"></span>
    </td>

</tr> <tr id="67600004" class="data charged show"></tr>

<tr class="infos" style="">

    <td colspan="11">
        <div class="infos"></div>
        <div class="minimap">
            <div class="indisponible" style="text-align: center; color: red; display: none; float: left;"></div>
            <div class="actions" style="display:block; float: right"></div>
            <div id="minimap67600004" class="olMap" style="height: 300px; width: 500px;">
                <div id="OpenLayers_Map_95_OpenLayers_ViewPort" class="olMapViewport olControlDragPanActive olControlZoomBoxActive olControlPinchZoomActive olControlNavigationActive" style="position: relative; overflow: hidden; width: 100%; height: 100%;">

    <div id="OpenLayers_Map_95_OpenLayers_Container" style="position: absolute; z-index: 749; left: 0px; top: 0px;">
        <div id="OpenLayers_Layer_WMTS_115" class="olLayerDiv olLayerGrid" style="position: absolute; width: 100%; height: 100%; z-index: 100;" dir="ltr"></div>

<div id="OpenLayers_Layer_Vector_126" class="olLayerDiv" style="position: absolute; width: 100%; height: 100%; z-index: 330; left: 0px; top: 0px;" dir="ltr">

    <svg id="OpenLayers_Layer_Vector_126_svgRoot" style="display: block;" width="500" height="300" viewBox="0 0 500 300">
        <g id="OpenLayers_Layer_Vector_126_root" style="visibility: visible;" transform="">
            <g id="OpenLayers_Layer_Vector_126_vroot">
                <image id="OpenLayers_Geometry_Point_128" cx="249.99999999988358" cy="149.99999998370185" r="1" preserveAspectRatio="none" x="242" y="141" width="15" height="18" xlink:href="/bundles/carto/images//interface/carto/pompe_vide.gif" style="opacity: 1" fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></image>

                                                                                    </g>
                                                                                    <g id="OpenLayers_Layer_Vector_126_troot"></g>
                                                                                </g>
                                                                            </svg>
                                                                        </div>
                                                                    </div>
                                                                    <div id="OpenLayers_Control_Zoom_98" class="olControlZoom olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on">
                                                                        <a class="olControlZoomIn olButton" href="#zoomIn">

                                                                        +

                                                                        </a>
                                                                        <a class="olControlZoomOut olButton" href="#zoomOut">

                                                                        −

                                                                        </a>
                                                                    </div>
                                                                    <div id="OpenLayers_Control_ArgParser_99" class="olControlArgParser olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on"></div>
                                                                    <div id="OpenLayers_Control_Attribution_100" class="olControlAttribution olControlNoSelect" style="position: absolute; z-index: 1004;" unselectable="on">                           Data ©

                                                                        <a target="_blank" href="http://www.openstreetmap.org/copyright/fr">

                                                                        OpenStreetMap

                                                                        </a>

                                                                        contributors

                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <input id="67600004_lat" type="hidden" value="48.2644252503"></input>
                                                            <input id="67600004_lon" type="hidden" value="7.44123443118"></input>
                                                        </div>
                                                        <span class="clear"></span>
                                                    </td>
                                                </tr>

0 个答案:

没有答案