Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!