How to create multiple windows of a web browser and access javascript objects inside windows (or frames)?
Essence is a service that performs certain calculations, but to use all the power, you need to keep 100-150 browser tabs open and at the same time monitor them for certain changes in the browser. Accordingly, it is necessary to open certain pages in the web browser, to get access to them and when events occur there, to notify the main program. And the browser window itself can not be displayed to save resources. Interested only in the introduction into the code run hundreds of pages from a program in C # (better) well, or Nodejs.

  • You place the COM object of the InternetExplorer.Application browser in the application window, the object has the script object and then access it. You can add scripts via Navigate("javascript:your_code;") Back to c # via Eval. - nick_n_a

1 answer 1

Chrome recently unveiled a special headless browser mode, i.e. A full browser is launched, but without UI. In parallel, they made a good nodejs libu to work with such a browser - puppeteer .

Here is a small example (more examples in the readme)

 const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com'); // Get the "viewport" of the page, as reported by the page. await page.evaluate(() => { return { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight, deviceScaleFactor: window.devicePixelRatio }; }); await browser.close(); })();