MeiK2333 / pyppeteer_stealth

MIT License
245 stars 53 forks source link

"pyppeteer_stealth" Module Not Found When Calling Python Script from PHP Script with "escapeshellcmd" Function #29

Closed iamvinny closed 1 year ago

iamvinny commented 1 year ago

Hello, I'm trying to execute a Python script that makes use of the pyppeteer_stealth module, the script works fine without importing the module, making use of just the regular pyppeteer, the problem occurs when I include the pyppeteer_stealth on the script, I get the following error:

Traceback (most recent call last):
  File "/var/www/html/hello.py", line 5, in <module>
    from pyppeteer_stealth import stealth
ModuleNotFoundError: No module named 'pyppeteer_stealth'

This is my PHP Script:

<?php

$command = escapeshellcmd('/usr/bin/python3 /var/www/html/hello.py');

$output = shell_exec($command);

echo "Output from Python script: ";
echo $output;

exit();

And this is the Python script (it works fine from the terminal the issue only happens when trying to execute from a web page)

#!/usr/bin/env python3

import asyncio
from pyppeteer import launch
from pyppeteer_stealth import stealth

async def main():
    browser = await launch(headless=True)
    page = await browser.newPage()

    await stealth(page)  # <-- Here

    await page.goto("https://bot.sannysoft.com/")
    await browser.close()

    print('success!')

asyncio.get_event_loop().run_until_complete(main())

Any tips on how to get it working would be appreciated!

iamvinny commented 1 year ago

!Solved.

The problem was related to user permissions to access the library.