[Python] Python with curl_cffi 0.10 - Is there a "wait for page load" option OR what should I...

Discussão em 'Python' iniciado por Stack, Abril 6, 2025.

  1. Stack

    Stack Membro Participativo

    This is the URL in question:

    https://www.lowes.com/pd/Metrie-Primed-Pine-Finger-Joint-Casing-9-16x2-1-4x7-5pc/5013107465

    Is there a way to wait using curl_cffi? I believe the expected page is not fully loading.

    response_product_url = session.get(product_url, impersonate="chrome")
    print(response_product_url.text)


    Sometimes it produces the expected webpage html, but that's not always the case. This is what it sends instead:

    <html>
    <body>
    <script src="/jCuYK/i5S/utYC/Cpki/heeN/c8uNLQ7Q/DUt0K2AC/FDMDTW/dYMjg?v=4837e545-2a73-ee94-1000-5bacad531738&t=241945205"></script>
    <script>
    (function() {
    var chlgeId = '';
    var scripts = document.getElementsByTagName('script');
    for (var i = 0; i < scripts.length; i++) {
    if (scripts.src && scripts.src.match(/t=([^&#]*)/)) {
    chlgeId = scripts.src.match(/t=([^&#]*)/)[1];
    }
    }
    var proxied = window.XMLHttpRequest.prototype.send;
    window.XMLHttpRequest.prototype.send = function() {
    var pointer = this
    var intervalId = window.setInterval(function() {
    if (pointer.readyState === 4 && pointer.responseURL && pointer.responseURL.indexOf('t=' + chlgeId) > -1) {
    location.reload(true);
    clearInterval(intervalId);
    }
    }, 1);
    return proxied.apply(this, [].slice.call(arguments));
    };
    })();
    </script>
    </body>
    </html>


    Thanks!

    Continue reading...

Compartilhe esta Página