Giter Site home page Giter Site logo

Comments (18)

marcusdiy avatar marcusdiy commented on June 23, 2024 1

In your examples you dont refer to extensions as it seems to be the main point now? there is no example too...
Btw doesn't the --load-extension= argument allow the installing of extensions? Sorry, I'm no expert just want to understand.
Maybe there is some caveat that I'm missing?

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024 1

Hmm strange, did you try passing the path of the extention or the .crx? Because the later seems to be more problematic. I can launch chrome via nodes spawn, providing the extention folder path, it works with headless too.

I tried different folder types in crx. However, when I tried, the Chromium library example was starting with chromium library. Now I am starting with @sparticuz/chromium. Maybe extensions can be loaded in this browser example.
If you can add your code and usage method with a video, I can update the library as soon as possible.

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024 1

You are welcome, the fact of using two browsers was just looking a bit strange to me...maybe there are other advantages that Im missing. Anyway .crx installation probably can be automated too becouse its just a zip in the end.

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024 1

Btw there is something wrong with my approach as it seems to fail cloudflare baypass... where you method works.
Maybe missing some flag? Will double check.

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024 1

Yes, thanks for the update. Here a test case.

import { connect } from 'puppeteer-real-browser'
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth'

puppeteer.use(StealthPlugin())
function sleep(ms) { return new Promise(res => setTimeout(res, ms)) }

connect({
    headless: 'auto', args: [], customConfig: {}, skipTarget: [],
    fingerprint: true, turnstile: true, connectOption: {},
    // proxy:{ host:'',  port:'', username:'', password:'' }
}).then(async response => {
    const { browser, page } = response
    await page.goto('https://nopecha.com/demo/cloudflare');
    await page.evaluate(() => { document.body.style.background = '#d9ffe7' });
    console.log('Now a new tab should appear');
    let page2 = await browser.newPage();
    console.log('...and it should goto cloudflare test page, but it won\'t');
    await page2.goto('https://nopecha.com/demo/cloudflare');
}).catch(error => {
    console.log(error.message)
})

I'll post an update soon

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024 1

Works, great success 👍
image

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024

Hello, the purpose of the second recommended usage is to be able to perform tasks such as installing Chrome extensions. When starting Chromium and providing the command to load a Chrome extension into flags, it does not install the extension. This situation applies only during the initial use. By default, a Chromium instance is launched and connected with Puppeteer without allowing for loading Chrome extensions when connecting with .connect. Therefore, those who do not require actions like installing extensions may prefer the default usage. However, for tasks such as installing Chrome extensions or specifying args, there is a need for the second usage.

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024

In your examples you dont refer to extensions as it seems to be the main point now? there is no example too... Btw doesn't the --load-extension= argument allow the installing of extensions? Sorry, I'm no expert just want to understand. Maybe there is some caveat that I'm missing?

The primary browser is not launched with puppeteer. We are launching it with Chromium. I tried to install an extension on Chromium via command line for a few hours, but it didn't work or I couldn't succeed, and I didn't have time to investigate this deeply. Therefore, I presented 2 usages. The first one starts Chromium and connects with puppeteer.connect to return the browser and page variables. Only 1 browser opens in this method. However, the Chrome extension cannot be loaded in this case.
The other one starts a chromium and returns the connection port. The rest of the process is up to the user. Just like when starting a normal puppeteer with .launch, you can use whatever you were using in that usage here as well.
https://stackoverflow.com/questions/67049065/puppeteer-unable-to-load-chrome-extension-in-browser
The reason why instructions for loading extensions are not provided in the second usage is that its usage is exactly the same as puppeteer's entirely. You can smoothly load the extension just like in the link provided above. However, a total of 2 browsers are run in this case.
Since it did not receive much attention by receiving stars from packages, I cannot dedicate much time to development. In the future, I plan to solve problems such as loading extensions and create a structure where all processes can be done with a single browser instance.

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

Hmm strange, did you try passing the path of the extention or the .crx? Because the later seems to be more problematic.
I can launch chrome via nodes spawn, providing the extention folder path, it works with headless too.

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

It goes something like this
puppeteer-load-extention

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024

It goes something like this puppeteer-load-extention

Thank you for your contributions. I will update the library soon.

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

At the end it seems to be boiling down to this. I still cant figure out why and how it works tho 😂
Why did you add that check? Thanks
image

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

Got a guess. Using your script if I call await browser.newPage() it wont work. But why?
Maybe its because its being filtered by targetFilter as so its kinda disconnected from puppeteer?
And thats why its not being detected by cloudflare too... so maybe there is a need for a way to connect and disconnect

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024

Got a guess. Using your script if I call await browser.newPage() it wont work. But why? Maybe its because its being filtered by targetFilter as so its kinda disconnected from puppeteer? And thats why its not being detected by cloudflare too... so maybe there is a need for a way to connect and disconnect

targetfilter prevents this. But I will definitely try to find a solution, I have updated the library. Thank you for your contributions.

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

Yes, thanks for the update. Here a test case.

import { connect } from 'puppeteer-real-browser'
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth'

puppeteer.use(StealthPlugin())
function sleep(ms) { return new Promise(res => setTimeout(res, ms)) }

connect({
    headless: 'auto', args: [], customConfig: {}, skipTarget: [],
    fingerprint: true, turnstile: true, connectOption: {},
    // proxy:{ host:'',  port:'', username:'', password:'' }
}).then(async response => {
    const { browser, page } = response
    await page.goto('https://nopecha.com/demo/cloudflare');
    console.log('Now a new tab should appear');
    let page2 = await browser.newPage();
    console.log('...and it should goto cloudflare test page, but it won\'t');
    await page2.goto('https://nopecha.com/demo/cloudflare');
}).catch(error => {
    console.log(error.message)
})

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

maybe a solution would be to disconnect puppeteer if certain url matches and connect to it later after making sure its not a protected page... btw the problem might still bite back if they check the framework presence on following pages

from puppeteer-real-browser.

zfcsoftware avatar zfcsoftware commented on June 23, 2024

let page2 = await browser.newPage();
console.log('...and it should goto cloudflare test page, but it won't');
await page2.goto('https://nopecha.com/demo/cloudflare');

I have released an update, could you please try and use it as it is in the readme file?

from puppeteer-real-browser.

marcusdiy avatar marcusdiy commented on June 23, 2024

Sure thing

from puppeteer-real-browser.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.