Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
Execute functions from website minified JS files in Selenium using Python

I'm trying to scrape some website and I'm trying to replicate some of the initiators of a XHR call. In order to do that, I want to use browser.execute_script(JS code here)

In there, I want to tell the browser to execute a function from one of the JS files the initiators are using. The function is the following. From what little I know about IIFE, it is a function that runs as soon as it is declared.

function(e) {
    var t = e.Loader
      , n = function(n) {
        function i() {
            var e = null !== n && n.apply(this, arguments) || this;
            return e.instanceCounter = i.Counter++,
            e
        }
        return __extends(i, n),
        i.prototype.load = function(i, o) {
            var r, s = this;
            o = o || {},
            e.url = i + (o && o.method != t.POST && o.urlVariables && "?" + o.urlVariables.serialize() || ""),
            e.body = o.data || "",
            o.customRequestHeaders || (o.customRequestHeaders = {}),
            r = function(e) {
                var t = e.detail;
                t && (window.removeEventListener("wan" + s.instanceCounter, r),
                o.customRequestHeaders["Serializer"] = t,
                n.prototype.load.call(s, i, o))
            }
            ,
            window.addEventListener("wan" + this.instanceCounter, r),
            window.dispatchEvent(new CustomEvent("wanr",{
                detail: this.instanceCounter
            }))
        }
        ,
        i.Counter = 0,
        i
    }(t);
    e.Loader2 = n
}(ganma || (ganma = {}))

In this file there are several IIFE functions and some of them make use of the ganma variable so it gets data before this function arrives.

How should I proceed? Do I create the var ganma = {key:value, key:value} and declare this function as IIFE?

script= var ganma = {...};return !function(e) {....}(ganma)

browser.execute_script(script)

Do I need to copy all of the IIFE functions in norder to reach the one I want? Besides, I feel like this file makes calls to functions in other files, is the browser able to handle it or should those be searched and declared as well?

If further details are needed, what would be the basis to try and accomplish this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda