scraping web con PHP Simple HTML DOM
Publicado por dave (13 intervenciones) el 03/07/2019 17:24:47
Que tal estoy trabajando haciendo raspado a paginas web utilizando PHP Simple HTML DOM, pero recientemente se me presento un problema por q no puedo raspar el contenido de un script... aca les mando el codigo q utilice y el script que necesito raspar...
este es el codigo q utilizo para raspar la pagina... todo extrae normal el problema esta en raspar el contenido de este script
este es el script del cual no puedo extraer el contenido.. alguien tiene alguna idea de como poder hacerlo les agradeceria su colaboracion..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require 'simple_html_dom.php';
$url = 'http://www.remax.bo/Terreno-En-Venta-Sacaba-Chapare_120020002-232?LFPNNSource=Search&cKey=120020002-232';
$html = file_get_html($url);
$posts = $html->find('div[class=listing-full mm-page mm-slideout]');
foreach ($posts as $post) {
/**$link = $post->find('div a', 0);
$a = $link->attr['href'];
$title = $link->innertext;*/
$titulo = $post->find('div[class=titlebar-listfull-h1] h1', 0);
$precio = $post->find('div[class=key-price-div] a', 0);
$zona = $post->find('div[class=key-data] div', 0);
$coord = $post->find('div[class=googlemap-office] script', 1);
echo "<table border='2'>";
echo "<tr>";
echo "<td>",$titulo,"\n","</td>";
echo "</tr>";
echo "<tr>";
echo "<td>",$precio,"\n","</td>";
echo "</tr>";
echo "<tr>";
echo "<td>",$zona,"\n","</td>";
echo "</tr>";
echo "<tr>";
echo "<td>",$coord,"\n","</td>";
echo "</tr>";
echo "</table>";
}
?>
este es el codigo q utilizo para raspar la pagina... todo extrae normal el problema esta en raspar el contenido de este script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script type="text/javascript">
var map = (function () {
var out = {};
var lat = -17.389444;
var lng = -66.103301;
var maxzoom = 19;
var opts = {
infoWindowContent: "",
infoWindowOnMarkerClick: "false",
zoom: 10,
marker: {
icon: "/common/images/GoogleMaps/pointer_1.png",
shadow: "/common/images/GoogleMaps/shadow_1.png",
title: ""
},
disabled: "false",
customMapPopup: "false"
};
var init = function (suffix) {
maps.LeafletOpenMap['initialize']('mapid-leaflet', lat, lng, opts);
}
out = {
initialize: init,
initializeOnDocumentReady: null,
initializeOnWindowReady: null,
onMapInitialized: null,
getOptions: function() { return opts; },
setOptions: function(o) { $.extend(opts, o); },
getMap: maps.LeafletOpenMap.getMap,
getMarker: null,
getLat: function() { return lat; },
getLng: function() { return lng; },
getMaxzoom: function() { return maxzoom; },
getMapProvider: function () { return 'LeafletOpenMaps'; }
}
return out;
})();
map.initialize();
// Attach map popup event listeners
function onMapClick(e) {
openCustomPopupWindow();
}
function onMarkerClick(e) {
openCustomPopupWindow();
}
function openCustomPopupWindow() {
var popup = window.open("", "openmap_popup", 'width=725,height=540,scrollbars=no,resizable=no,titlebar=no,location=no,status=no');
}
</script>
este es el script del cual no puedo extraer el contenido.. alguien tiene alguna idea de como poder hacerlo les agradeceria su colaboracion..
Valora esta pregunta


0