L
lordraven
Curioso
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Buenas estoy trabajando con simple html dom, hasta ayer normal el trabajo de las paginas pero me salio un error, al continuar con el raspado de una pagina.
Advertencias: file_get_contents (https://www.plusvalia.com/departamentos-en-venta-en-quito-pagina-9.html): no se pudo abrir la secuencia: ¡Error en la solicitud HTTP! HTTP / 1.1 403 Prohibido en C: \ xampp \ htdocs \ scrapcsv \ ecuador \ quito \ simple_html_dom.php en la línea 136
luego de verificar la página al intentar ingresar me pide:
mi consulta es si hay alguna manera de pasar eso y seguir con el raspado de la página intente de varias maneras pero aún no hay logro dar con algún método.
adjunto mi código de raspado:
[CÓDIGO] <? Php
$ db = nuevo PDO ('mysql: host = localhost; dbname = infosantacruz; charset = utf8mb4', 'root', '');
$ db-> setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION);
$ db-> setAttribute (PDO :: ATTR_EMULATE_PREPARES, falso);
requiere 'simple_html_dom.php';
$ url = 'https://www.plusvalia.com/departamentos-en-venta-en-quito-pagina-9.html';
$ html = file_get_html ($ url);
$ posts = $ html-> find ('div [clase = publishing-header]');
foreach ($ publicaciones como $ publicaciones) {
$ link = $ post-> find ('h3 a', 0);
$ url = $ enlace-> attr ['href'];
$ title = $ link-> innertext;
$ url = 'https: //www.plusvalia.com'.$url;
echo "<table border = '2'>";
echo "<tr>";
echo "<td>", $ url, "\ n", "</td>";
echo "</tr>";
echo "</table>";
$ html = file_get_html ($ url);
$ posts = $ html-> find ('div [id = main-container]');
foreach ($ publicaciones como $ publicaciones) {
$ titulo = $ post-> find ('div [clase = sección-título] h1', 0);
$ prec = $ post-> find ('div [clase = bloque-precio bloque-fila] div', 1);
$ prec2 = $ post-> find ('div [clase = fila css-border-n] span', 1);
$ precio = $ prec. $ prec2;
// $ telefono = $ post-> find ('div [clase = mdl mdlContent-simpleCenter mdl-modal mdl-modal-postlead] a', 0) -> attr ['href'];
$ latitud = $ post-> find ('div [class = article-map] img', 0) -> attr ['src'];
$ longitud = $ post-> find ('div [class = article-map] img', 0) -> attr ['src'];
$ a = $ post-> find ('li [clase = icono-característica] b', 0);
$ b = $ post-> find ('li [class = icon-feature] span', 0);
$ datos1 = $ a. $ b;
$ c = $ post-> find ('li [clase = icono-característica] b', 1);
$ d = $ post-> find ('li [class = icon-feature] span', 1);
$ datos2 = $ c. $ d;
$ e = $ post-> find ('li [clase = icono-característica] b', 2);
$ f = $ post-> find ('li [class = icon-feature] span', 2);
$ datos3 = $ e. $ f;
$ g = $ post-> find ('li [clase = icono-característica] b', 3);
$ h = $ post-> find ('li [class = icon-feature] span', 3);
$ datos4 = $ g. $ h;
$ i = $ post-> find ('li [clase = icono-característica] b', 4);
$ j = $ post-> find ('li [class = icon-feature] span', 4);
$ datos5 = $ i. $ j;
$ k = $ post-> find ('li [clase = icono-característica] b', 5);
$ l = $ post-> find ('li [class = icon-feature] span', 5);
$ datos6 = $ k. $ l;
$ m = $ post-> find ('li [clase = icono-característica] b', 6);
$ n = $ post-> find ('li [class = icon-feature] span', 6);
$ datos7 = $ m. $ n;
$ publi = $ post-> find ('section [class = general-section article-section article-section-description] h5', 0);
$ serv = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 1);
$ serv1 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 2);
$ serv2 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 3);
$ serv3 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 4);
$ serv4 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 5);
$ serv5 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 6);
$ serv6 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 7);
$ serv7 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 8);
$ observa = $ serv. $ serv1. $ serv2. $ serv3. $ serv4. $ serv5. $ serv6. $ serv7;
$ zona = $ post-> find ('div [clase = sección-ubicación] b', 0);
$ link = $ post-> find ('figure img', 0);
$ img = $ link-> attr ['data-flickity-lazyload'];
// $ link = $ post-> find ('div img', 1);
// $ im = $ link-> attr ['src'];
$ im = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 0) -> attr ['src'];
$ imagen = $ img. $ im;
$ link = $ post-> find ('figure img', 1);
$ img1 = $ link-> attr ['data-flickity-lazyload'];
$ im1 = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 1) -> attr ['src'];
// $ link = $ post-> find ('div img', 2);
// $ im1 = $ link-> attr ['src'];
$ imagen1 = $ img1. $ im1;
$ link = $ post-> find ('figure img', 2);
$ img2 = $ link-> attr ['data-flickity-lazyload'];
$ im2 = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 2) -> attr ['src'];
// $ link = $ post-> find ('div img', 3);
// $ im2 = $ link-> attr ['src'];
$ imagen2 = $ img2. $ im2;
$ link = $ post-> find ('figure img', 3);
$ img3 = $ link-> attr ['data-flickity-lazyload'];
$ im3 = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 3) -> attr ['src'];
// $ link = $ post-> find ('div img', 4);
// $ im3 = $ link-> attr ['src'];
$ imagen3 = $ img3. $ im3;
$ link = $ post-> find ('figure img', 4);
$ imagen4 = $ link-> attr ['data-flickity-lazyload'];
echo "++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++ ";
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>", $ longitud, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ latitud, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos1, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos2, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos3, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos4, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos5, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos6, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos7, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ publi, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
// echo "<td>", $ telefono, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ observa, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ zona, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ imagen, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen1, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen2, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen3, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen4, "\ n", "</td>";
echo "</tr>";
echo "<td>", $ im, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ im1, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ im2, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ im3, "\ n", "</td>";
echo "</tr>";
echo "</table>";
$ stmt = $ db-> prepare ("INSERT INTO quitoplusdptos (titulo, precio, longitud, latitud, datos1, datos2, datos3, datos4, datos5, datos6, datos7, publi, telefono, observa, zona, url, imagen, imagen1, imagen2, imagen3, imagen4) VALORES 🙂 titulo,: precio,: longitud,: latitud,: datos1,: datos2,: datos3,: datos4,: datos5,: datos6,: datos7,: publi,: telefono,: observa, : zona,: url,: imagen,: imagen1,: imagen2,: imagen3,: imagen4) ");
$ stmt-> execute (array (
': titulo' => $ titulo,
': precio' => $ precio,
': longitud' => $ longitud,
': latitud' => $ latitud,
': datos1' => $ datos1,
': datos2' => $ datos2,
': datos3' => $ datos3,
': datos4' => $ datos4,
': datos5' => $ datos5,
': datos6' => $ datos6,
': datos7' => $ datos7,
': publi' => $ publi,
': telefono' => $ telefono,
': observa' => $ observa,
': zona' => $ zona,
': url' => $ url,
': imagen' => $ imagen,
': imagen1' => $ imagen1,
': imagen2' => $ imagen2,
': imagen3' => $ imagen3,
': imagen4' => $ imagen4));
$fected_rows = $ stmt-> rowCount ();
}
} [/ CÓDIGO]
Me seria de mucha ayuda si alguien pudo resolver alguna vez esto, o si tenía algún método para pasar esto ... Gracias
Advertencias: file_get_contents (https://www.plusvalia.com/departamentos-en-venta-en-quito-pagina-9.html): no se pudo abrir la secuencia: ¡Error en la solicitud HTTP! HTTP / 1.1 403 Prohibido en C: \ xampp \ htdocs \ scrapcsv \ ecuador \ quito \ simple_html_dom.php en la línea 136
luego de verificar la página al intentar ingresar me pide:
mi consulta es si hay alguna manera de pasar eso y seguir con el raspado de la página intente de varias maneras pero aún no hay logro dar con algún método.
adjunto mi código de raspado:
[CÓDIGO] <? Php
$ db = nuevo PDO ('mysql: host = localhost; dbname = infosantacruz; charset = utf8mb4', 'root', '');
$ db-> setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION);
$ db-> setAttribute (PDO :: ATTR_EMULATE_PREPARES, falso);
requiere 'simple_html_dom.php';
$ url = 'https://www.plusvalia.com/departamentos-en-venta-en-quito-pagina-9.html';
$ html = file_get_html ($ url);
$ posts = $ html-> find ('div [clase = publishing-header]');
foreach ($ publicaciones como $ publicaciones) {
$ link = $ post-> find ('h3 a', 0);
$ url = $ enlace-> attr ['href'];
$ title = $ link-> innertext;
$ url = 'https: //www.plusvalia.com'.$url;
echo "<table border = '2'>";
echo "<tr>";
echo "<td>", $ url, "\ n", "</td>";
echo "</tr>";
echo "</table>";
$ html = file_get_html ($ url);
$ posts = $ html-> find ('div [id = main-container]');
foreach ($ publicaciones como $ publicaciones) {
$ titulo = $ post-> find ('div [clase = sección-título] h1', 0);
$ prec = $ post-> find ('div [clase = bloque-precio bloque-fila] div', 1);
$ prec2 = $ post-> find ('div [clase = fila css-border-n] span', 1);
$ precio = $ prec. $ prec2;
// $ telefono = $ post-> find ('div [clase = mdl mdlContent-simpleCenter mdl-modal mdl-modal-postlead] a', 0) -> attr ['href'];
$ latitud = $ post-> find ('div [class = article-map] img', 0) -> attr ['src'];
$ longitud = $ post-> find ('div [class = article-map] img', 0) -> attr ['src'];
$ a = $ post-> find ('li [clase = icono-característica] b', 0);
$ b = $ post-> find ('li [class = icon-feature] span', 0);
$ datos1 = $ a. $ b;
$ c = $ post-> find ('li [clase = icono-característica] b', 1);
$ d = $ post-> find ('li [class = icon-feature] span', 1);
$ datos2 = $ c. $ d;
$ e = $ post-> find ('li [clase = icono-característica] b', 2);
$ f = $ post-> find ('li [class = icon-feature] span', 2);
$ datos3 = $ e. $ f;
$ g = $ post-> find ('li [clase = icono-característica] b', 3);
$ h = $ post-> find ('li [class = icon-feature] span', 3);
$ datos4 = $ g. $ h;
$ i = $ post-> find ('li [clase = icono-característica] b', 4);
$ j = $ post-> find ('li [class = icon-feature] span', 4);
$ datos5 = $ i. $ j;
$ k = $ post-> find ('li [clase = icono-característica] b', 5);
$ l = $ post-> find ('li [class = icon-feature] span', 5);
$ datos6 = $ k. $ l;
$ m = $ post-> find ('li [clase = icono-característica] b', 6);
$ n = $ post-> find ('li [class = icon-feature] span', 6);
$ datos7 = $ m. $ n;
$ publi = $ post-> find ('section [class = general-section article-section article-section-description] h5', 0);
$ serv = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 1);
$ serv1 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 2);
$ serv2 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 3);
$ serv3 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 4);
$ serv4 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 5);
$ serv5 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 6);
$ serv6 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 7);
$ serv7 = $ post-> find ('sección [clase = sección-general sección-artículo] h4', 8);
$ observa = $ serv. $ serv1. $ serv2. $ serv3. $ serv4. $ serv5. $ serv6. $ serv7;
$ zona = $ post-> find ('div [clase = sección-ubicación] b', 0);
$ link = $ post-> find ('figure img', 0);
$ img = $ link-> attr ['data-flickity-lazyload'];
// $ link = $ post-> find ('div img', 1);
// $ im = $ link-> attr ['src'];
$ im = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 0) -> attr ['src'];
$ imagen = $ img. $ im;
$ link = $ post-> find ('figure img', 1);
$ img1 = $ link-> attr ['data-flickity-lazyload'];
$ im1 = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 1) -> attr ['src'];
// $ link = $ post-> find ('div img', 2);
// $ im1 = $ link-> attr ['src'];
$ imagen1 = $ img1. $ im1;
$ link = $ post-> find ('figure img', 2);
$ img2 = $ link-> attr ['data-flickity-lazyload'];
$ im2 = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 2) -> attr ['src'];
// $ link = $ post-> find ('div img', 3);
// $ im2 = $ link-> attr ['src'];
$ imagen2 = $ img2. $ im2;
$ link = $ post-> find ('figure img', 3);
$ img3 = $ link-> attr ['data-flickity-lazyload'];
$ im3 = $ post-> find ('div [clase = elemento-galería js-openDevelopmentMultimedia] img', 3) -> attr ['src'];
// $ link = $ post-> find ('div img', 4);
// $ im3 = $ link-> attr ['src'];
$ imagen3 = $ img3. $ im3;
$ link = $ post-> find ('figure img', 4);
$ imagen4 = $ link-> attr ['data-flickity-lazyload'];
echo "++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++ ";
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>", $ longitud, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ latitud, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos1, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos2, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos3, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos4, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos5, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos6, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ datos7, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ publi, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
// echo "<td>", $ telefono, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ observa, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ zona, "\ n", "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>", $ imagen, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen1, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen2, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen3, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ imagen4, "\ n", "</td>";
echo "</tr>";
echo "<td>", $ im, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ im1, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ im2, "\ n", "</td>";
echo "<tr>";
echo "<td>", $ im3, "\ n", "</td>";
echo "</tr>";
echo "</table>";
$ stmt = $ db-> prepare ("INSERT INTO quitoplusdptos (titulo, precio, longitud, latitud, datos1, datos2, datos3, datos4, datos5, datos6, datos7, publi, telefono, observa, zona, url, imagen, imagen1, imagen2, imagen3, imagen4) VALORES 🙂 titulo,: precio,: longitud,: latitud,: datos1,: datos2,: datos3,: datos4,: datos5,: datos6,: datos7,: publi,: telefono,: observa, : zona,: url,: imagen,: imagen1,: imagen2,: imagen3,: imagen4) ");
$ stmt-> execute (array (
': titulo' => $ titulo,
': precio' => $ precio,
': longitud' => $ longitud,
': latitud' => $ latitud,
': datos1' => $ datos1,
': datos2' => $ datos2,
': datos3' => $ datos3,
': datos4' => $ datos4,
': datos5' => $ datos5,
': datos6' => $ datos6,
': datos7' => $ datos7,
': publi' => $ publi,
': telefono' => $ telefono,
': observa' => $ observa,
': zona' => $ zona,
': url' => $ url,
': imagen' => $ imagen,
': imagen1' => $ imagen1,
': imagen2' => $ imagen2,
': imagen3' => $ imagen3,
': imagen4' => $ imagen4));
$fected_rows = $ stmt-> rowCount ();
}
} [/ CÓDIGO]
Me seria de mucha ayuda si alguien pudo resolver alguna vez esto, o si tenía algún método para pasar esto ... Gracias