perplexity-ai icon indicating copy to clipboard operation
perplexity-ai copied to clipboard

Strangely not always works

Open VooDisss opened this issue 10 months ago • 5 comments

For it to work, i have to:

  1. close chrome browser and CMD window
  2. open CMD again and enter ```python launch.py'''
  3. Then it gives the output which i give below
  4. gets stuck at "new account created" and nothing happens and I have to try doing it again from step 1.

Output:

Creating new account
Account creation error Expecting value: line 1 column 1 (char 0)
Renewing emailnator cookies
Exception in thread Thread-1 (account_creator):
Traceback (most recent call last):
  File "C:\Users\Username\Downloads\perplexity-ai-main\perplexity\driver.py", line 29, in account_creator
    emailnator_cli = Emailnator(self.emailnator_cookies, {**self.emailnator_headers, 'x-xsrf-token': unquote(self.emailnator_cookies['XSRF-TOKEN'])})
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\Downloads\perplexity-ai-main\perplexity\emailnator.py", line 50, in __init__
    resp = self.s.post('https://www.emailnator.com/generate-email', json=data).json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\curl_cffi\requests\models.py", line 205, in json
    return loads(self.content, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\__init__.py", line 346, in loads
Exception in callback SyncBase._sync.<locals>.<lambda>(<Task finishe...il "load"\n')>) at C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_sync_base.py:93
handle: <Handle SyncBase._sync.<locals>.<lambda>(<Task finishe...il "load"\n')>) at C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_sync_base.py:93>
Traceback (most recent call last):
  File "C:\Python312\Lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_sync_base.py", line 93, in <lambda>
    task.add_done_callback(lambda _: g_self.switch())
                                     ^^^^^^^^^^^^^^^
greenlet.error: Cannot switch to a different thread
        Current:  <greenlet.greenlet object at 0x00000279D4AC1CC0 (otid=0x00000279D71212F0) suspended active started main>
        Expected: <greenlet.greenlet object at 0x00000279D8083E00 (otid=0x00000279D808FA20) suspended active started main>
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python312\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "C:\Python312\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Username\Downloads\perplexity-ai-main\perplexity\driver.py", line 55, in account_creator
    self.page.goto('https://www.emailnator.com/')
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\sync_api\_generated.py", line 8803, in goto
    self._sync(
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_sync_base.py", line 95, in _sync
    self._dispatcher_fiber.switch()
greenlet.error: Cannot switch to a different thread
        Current:  <greenlet.greenlet object at 0x00000279D8083E00 (otid=0x00000279D808FA20) current active started main>
        Expected: <greenlet.greenlet object at 0x00000279D4AC1CC0 (otid=0x00000279D71212F0) suspended active started main>
Creating new account
Error occurred in event listener
Traceback (most recent call last):
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 284, in handle
    return await self._handle_internal(route)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 314, in _handle_internal
    await handler_finished_future
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 307, in _handler
    self.handler(route, route.request)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_impl_to_api_mapping.py", line 109, in wrapper_func
    return handler(
           ^^^^^^^^
  File "C:\Users\Username\Downloads\perplexity-ai-main\perplexity\driver.py", line 104, in intercept_request
    self.page.wait_for_timeout(1000)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\sync_api\_generated.py", line 11227, in wait_for_timeout
    self._sync(self._impl_obj.wait_for_timeout(timeout=timeout))
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_sync_base.py", line 97, in _sync
    return task.result()
           ^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_page.py", line 1027, in wait_for_timeout
    await self._main_frame.wait_for_timeout(timeout)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_frame.py", line 704, in wait_for_timeout
    await self._channel.send("waitForTimeout", locals_to_params(locals()))
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_connection.py", line 46, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_connection.py", line 478, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
patchright._impl._errors.TargetClosedError: Page.wait_for_timeout: Target page, context or browser has been closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_page.py", line 278, in _on_route
    handled = await route_handler.handle(route)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 290, in handle
    raise rewrite_error(
patchright._impl._errors.TargetClosedError: "Page.wait_for_timeout: Target page, context or browser has been closed" while running route callback.
Consider awaiting `page.unroute_all(behavior='ignoreErrors')`
before the end of the test to ignore remaining routes in flight.
Error occurred in event listener
Traceback (most recent call last):
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 284, in handle
    return await self._handle_internal(route)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 314, in _handle_internal
    await handler_finished_future
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 307, in _handler
    self.handler(route, route.request)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_impl_to_api_mapping.py", line 109, in wrapper_func
    return handler(
           ^^^^^^^^
  File "C:\Users\Username\Downloads\perplexity-ai-main\perplexity\driver.py", line 104, in intercept_request
    self.page.wait_for_timeout(1000)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\sync_api\_generated.py", line 11227, in wait_for_timeout
    self._sync(self._impl_obj.wait_for_timeout(timeout=timeout))
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_sync_base.py", line 97, in _sync
    return task.result()
           ^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_page.py", line 1027, in wait_for_timeout
    await self._main_frame.wait_for_timeout(timeout)
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_frame.py", line 704, in wait_for_timeout
    await self._channel.send("waitForTimeout", locals_to_params(locals()))
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_connection.py", line 46, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_connection.py", line 478, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
patchright._impl._errors.TargetClosedError: Page.wait_for_timeout: "Page.wait_for_timeout: Target page, context or browser has been closed" while running route callback.
Consider awaiting `page.unroute_all(behavior='ignoreErrors')`
before the end of the test to ignore remaining routes in flight.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_page.py", line 278, in _on_route
    handled = await route_handler.handle(route)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Username\AppData\Roaming\Python\Python312\site-packages\patchright\_impl\_helper.py", line 290, in handle
    raise rewrite_error(
patchright._impl._errors.TargetClosedError: "Page.wait_for_timeout: "Page.wait_for_timeout: Target page, context or browser has been closed" while running route callback.
Consider awaiting `page.unroute_all(behavior='ignoreErrors')`
before the end of the test to ignore remaining routes in flight." while running route callback.
Consider awaiting `page.unroute_all(behavior='ignoreErrors')`
before the end of the test to ignore remaining routes in flight.
New account created```

VooDisss avatar Mar 02 '25 22:03 VooDisss

Well, i made some good changes but Web Interface is problematic per se :\ The new version looks like working better, ignore the error messages if they don't block anything.

helallao avatar Mar 03 '25 10:03 helallao

@helallao I can't get anything to work from your repo.

heymegangarcia avatar Mar 18 '25 17:03 heymegangarcia

@helallao I can't get anything to work from your repo.

could you explain what exactly does not work..?

dominicOT avatar Mar 24 '25 02:03 dominicOT

Still it is not stable and works every third time... Still it's better than doing the work manually :D But could be improved

VooDisss avatar Mar 26 '25 05:03 VooDisss

I think now they have a human verification on perplexity endpoint...

cybersecuritylearning avatar Apr 12 '25 10:04 cybersecuritylearning