kameleo-io / local-api-client-typescript

Official JavaScript/TypeScript library for interacting with Kameleo Client
https://kameleo.io/learn-more/automation
MIT License
45 stars 2 forks source link

How to run scraper code on Linux while Kameleo is running on Windows #5

Closed JonathanR25 closed 6 months ago

JonathanR25 commented 6 months ago

I'd like to know whether it's possible to run Kameleo.CLI on a Windows machine and to launch Playwright instances on a Linux machine using Javascript?

MBailey01 commented 6 months ago

There is a guide that explains this thoroughly, it can be viewed by accessing https://help.kameleo.io/hc/en-us/articles/13400684344476-Run-scraper-code-on-Linux-while-Kameleo-is-running-on-Windows Setting up Kameleo.CLI on Windows involves a few key steps to ensure accessibility and configuration. Here's how to proceed:

Configure Kameleo.CLI on Windows

Ensure Kameleo.CLI is Running: First, confirm that Kameleo.CLI is operational on your Windows machine and reachable from the network.

Open Port 5050: If port 5050 is not already open, modify your Windows firewall settings to permit incoming connections on this port.

Verify Accessibility: From your Linux machine, attempt to access http://IP_OF_WINDOWS_MACHINE:5050/swagger in a web browser. If successful, you should see the Kameleo.CLI API documentation, confirming connectivity.

Next, update your client configuration to connect to Kameleo.CLI using its network IP address:

Depending on whether you use Javascript or Python:

const kameleoPort = 5050;
const client = new KameleoLocalApiClient({
  baseUri: `http://IP_OF_WINDOWS_MACHINE:${kameleoPort}`,
  noRetryPolicy: true,
});

Make sure to replace the IP_OF_WINDOWS_MACHINE with the actual IP address of your Windows machine.

Next, set up Playwright on your Linux machine to establish a connection with the Kameleo.CLI instance running on Windows.

const browserWSEndpoint = ws://IP_OF_WINDOWS_MACHINE:${kameleoPort}/playwright/${profile.id};