ulixee / hero

The web browser built for scraping
MIT License
774 stars 41 forks source link

Example with PlaygroundHero not working #287

Open NN-Binary opened 1 month ago

NN-Binary commented 1 month ago

Hi Hi!

const { Hero: PlaygroundHero } = require('@ulixee/hero-playground');

  // starts a Hero Core and automatically connects
  const local = new PlaygroundHero({
            maxConcurrency: 1, 
            dataDir: path.join(SETTINGS.InternalChromeFiles, sha256(ProfileID))
        });

The base example doesn't seem to work, it says that PlaygroundHero is not a constructor (I run that on a fresh script to be sure).

Additionally, the standard Cloud example does not seem to work:

async function GetHeroPlayground(ProfileID) {

    const cloudNode = new CloudNode();

    let CloudObject = { 
        hostname: CLOUD_SERVER.hostname || CLOUD_SERVER.ip,
        port: CLOUD_SERVER.port
    };

    // We need many available ports, to do that, we get the list of currently taken port
    await cloudNode.listen(CloudObject);

    return `${CloudObject.hostname}:${CloudObject.port}`;

}

    let InstanceHost = await GetHeroPlayground();

    INSTANCES[ProfileID] = await new Hero({
        connectionToCore: {
            host: InstanceHost, 
        },
       ....
    });

This actually listen and create a socket, but connectionToCore does not connect to the right Cloud (the string is correct), it always recreate localhost:1818

blakebyrnes commented 1 month ago

Hi @NN-Binary... First want to make sure you understand that Hero Playground is a test setup so that you DON'T have to create a cloud instance. It's meant to make testing simple to start. Where did you find an "example" that looks like either of these setups so I know what to fix/compare to?

Second, you appear to be using commonjs without typescript. Hero is the default export from @ulixee/hero-plaground, so would not work as you coded it because I don't think it's a named export.

blakebyrnes commented 2 weeks ago

@NN-Binary You've obviously moved on from this ticket. Did you have a resolution for playgrounds?