Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda