0

Tengo un archivo llamado: scraping_phantomjs_ajax.js y llamo desde python y contiene:

var webPage = require('webpage');
var system = require('system');
var args = system.args;
var page = webPage.create();
var url = args[1]

/*Agregamos para renderizar reactjs*/
page.onInitialized = function() {
    if(page.injectJs('core-js3_4_1.1.js')){
    }    
}

page.open(url, function(status) {
    setTimeout(function() {
        var content = page.content;
        console.log(status);
        phantom.exit();
    }, 200);
});

y tengo al .py que llamo de esta forma

import subprocess, sys, os
url = "https://larepublica.pe/"
url = "https://larepublica.pe/tecnologia/"
result = subprocess.check_output(['/home/alejandro/Descargas/phantomjs-2.1.1-linux-x86_64/bin/phantomjs', 
    'scraping_phantomjs_ajax.js', url])

print ("HTML:", result)

Como se ve en scraping_phantomjs_ajax.js he inyectado core-js3_4_1.1.js, esto me permite renderizar sitios con REACTJS, en particular en la larepublica.pe cuando hago petición al index sí me responde el renderizado en html correcto, pero cuando peticiono por ejemplo a otras secciones como /tecnologia, /economia, etc, no me devuelve el html realmente renderizado.

Obtengo este tipo de Error, desconozco lo que puede estar pasando, alguna solución?:

b'TypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\')\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nTypeError: undefined is not a function (evaluating \'f[0].name.toLowerCase().normalize("NFD")\') [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nReferenceError: Can\'t find variable: Intl\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:22 in pa\nReferenceError: Can\'t find variable: Intl [object Object]\n\n  https://larepublica.pe/pf/dist/engine/react.js?d=431:31 in value\nsuccess\n'

1 respuesta 1

0

Lo he resuelto actualizando phantomjs2.1 a phantomjs2.5 y actualizando core.js a core-js3.4.1.js y funciona perfectamente

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.