Google 地图,抓取地址

Google Maps, scraping address

我正在使用 cheerio 来抓取下一个 html。

<div class="google-map-wrap " style="padding-bottom:50px;">
<div class="google-map"></div><style>.google-map{width: 100%; height: 420px;} 
.google-map img {max-width:none !important;}</style><script>jQuery(document).ready(function(){jQuery(".google-map").gmap3({marker:{address: "Periferico Sur 2020"},map:{options:{zoom: 14,}}});});

我尝试了以下选项,但都没有用。

预计="Periferico Sur 2020"

$('div.google-map-wrap div.google-map').text()

$('div.google-map-wrap div.google-map').html()

$('div.google-map-wrap div.google-map').css()

但是不工作结果应该是地址。

如前所述,cheerio 无法做到这一点。但是请求已经有 html 所以我们可以用它来找到带有 indexOf() 的字符串。示例:

.html

<div class="google-map-wrap " style="padding-bottom:50px;">
<div class="google-map"></div><style>.google-map{width: 100%; height: 420px;} 
.google-map img {max-width:none !important;}</style>
<script>jQuery(document).ready(function(){jQuery(".google-map").gmap3({marker:{address: "Periferico Sur 2020"},map:{options:{zoom: 14,}}});});

.js

var readAddress = function(html){
 var idx1 = html.indexOf('{marker:{address: "');
 var idx2 = idx1 + '{marker:{address: "'.length;
 var idx3 = html.indexOf('"', idx2);

address = html.substring(idx2, idx3);
}

request(url, (err, res, data) => {
    readAddress(data);
 });