Coder Social home page Coder Social logo

chrome-profiles-in-multithread's Introduction

Handle multiple Chrome profile instance using thread

1. git clone https://github.com/piriyaraj/chrome-profiles-in-multithread.git
2. cd chrome-profiles-in-multithread
3. python -m venv venv
4. venv\Scripts\activate
5. pip install -r requirements.txt

go to venv\Lib\site-packages\undetected_chromedriver\patcher.py

you can see a function called unzip_package as below

    def unzip_package(self, fp):
        """
        Does what it says

        :return: path to unpacked executable
        """
        exe_path = self.exe_name
        if not self.is_old_chromedriver:
            # The new chromedriver unzips into its own folder
            zip_name = f"chromedriver-{self.platform_name}"
            exe_path = os.path.join(zip_name, self.exe_name)

        logger.debug("unzipping %s" % fp)
        try:
            os.unlink(self.zip_path)
        except (FileNotFoundError, OSError):
            pass

        os.makedirs(self.zip_path, mode=0o755, exist_ok=True)
        with zipfile.ZipFile(fp, mode="r") as zf:
            zf.extractall(self.zip_path)
        os.rename(os.path.join(self.zip_path, exe_path), self.executable_path)
        os.remove(fp)
        shutil.rmtree(self.zip_path)
        os.chmod(self.executable_path, 0o755)
        return self.executable_path

change it as

    def unzip_package(self, fp):
        """
        Does what it says

        :return: path to unpacked executable
        """
        exe_path = self.exe_name
        if not self.is_old_chromedriver:
            # The new chromedriver unzips into its own folder
            zip_name = f"chromedriver-{self.platform_name}"
            exe_path = os.path.join(zip_name, self.exe_name)

        logger.debug("unzipping %s" % fp)
        try:
            os.unlink(self.zip_path)
        except (FileNotFoundError, OSError):
            pass

        os.makedirs(self.zip_path, mode=0o755, exist_ok=True)
        with zipfile.ZipFile(fp, mode="r") as zf:
            zf.extractall(self.zip_path)
        try:
            os.rename(os.path.join(self.zip_path, exe_path), self.executable_path)
            os.remove(fp)
            shutil.rmtree(self.zip_path)
        except:
            pass
        os.chmod(self.executable_path, 0o755)
        return self.executable_path

run python main.py

It will open the 3 new profile and save it in a folder called profiles for using next execution.

in the main.py you can add new profiles as much as you want. every profile works in same time

your can use it for

Parallel Execution: Run multiple Chrome profiles simultaneously for efficiency.
Isolation: Keep profiles independent for separate tasks or configurations.
Resource Efficiency: Minimize resource usage by using threads instead of processes.
Easy Management: Simplify profile management and customization in main.py.
Profile Persistence: Save profiles for reuse in future executions.
Customization: Customize each profile with extensions and settings.
Debugging and Monitoring: Monitor and debug issues more effectively.
Scalability: Scale the number of profiles to meet your needs.

chrome-profiles-in-multithread's People

Contributors

piriyaraj avatar

Watchers

 avatar

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.