如前所述,cheerio将无法做到这一点。但是request已经有了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);
});