Skip to content

wingeva1986/perplexity-ai

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perplexity.ai

This module is simply just an API Wrapper and account generator. So it's an API Wrapper with free copilots.

How It Works

This module uses emailnator to generate new accounts. As you know, when you create a new account, you will have 5 copilots. That's how it works! This module will generate you new gmails (using @googlemail.com right now) with emailnator and you will have UNLIMITED COPILOTS!

Requirements

Install requirements with:

pip3 install -r requirements.txt

or with single-line command:

pip3 install requests&&pip3 install beautifulsoup4&&pip3 install lxml&&pip3 install websocket-client&&pip3 install requests-toolbelt

and aiohttp if you are going to use asynchronous version:

pip3 install aiohttp

How To Use

First thing first, Perplexity.ai is protected by cloudflare, and emailnator too. We need to open this pages manually and get the cookies. And do not forget these cookies are temporary, so you need to renew them continuously. Here how to get your cookies.

import perplexity

perplexity_headers = <your headers here>
perplexity_cookies = <your cookies here>

emailnator_headers = <your headers here>
emailnator_cookies = <your cookies here>


perplexity_cli = perplexity.Client(perplexity_headers, perplexity_cookies)
perplexity_cli.create_account(emailnator_headers, emailnator_cookies) # Creates a new gmail, so your 5 copilots will be renewed. You can pass this one if you are not going to use "copilot" mode

# modes = ['concise', 'copilot']
# focus = ['internet', 'scholar', 'writing', 'wolfram', 'youtube', 'reddit', 'wikipedia']
# file = (data, filetype) perplexity supports two file types, txt and pdf
print(perplexity_cli.search('Your query here', mode='copilot', focus='internet', file=(open('myfile.txt', 'rb').read(), 'txt')))

# perplexity_cli.create_account(emailnator_headers, emailnator_cookies) # Call this function when you're out of copilots

How To Use Asynchronous Version

import perplexity_async
import asyncio

perplexity_headers = <your headers here>
perplexity_cookies = <your cookies here>

emailnator_headers = <your headers here>
emailnator_cookies = <your cookies here>


async def test():
    perplexity_cli = await perplexity_async.Client(perplexity_headers, perplexity_cookies)
    await perplexity_cli.create_account(emailnator_headers, emailnator_cookies) # Creates a new gmail, so your 5 copilots will be renewed. You can pass this one if you are not going to use "copilot" mode

    # modes = ['concise', 'copilot']
    # focus = ['internet', 'scholar', 'writing', 'wolfram', 'youtube', 'reddit', 'wikipedia']
    # file = (data, filetype) perplexity supports two file types, txt and pdf
    print(await perplexity_cli.search('Your query here', mode='copilot', focus='internet', file=(open('myfile.txt', 'rb').read(), 'txt')))

    # await perplexity_cli.create_account(emailnator_headers, emailnator_cookies) # Call this function when you're out of copilots

asyncio.run(test())

How To Get The Cookies

Do not forget these cookies are temporary, so you need to renew them continuously.

  1. Open emailnator website. Click F12 or Ctrl + Shift + I to open inspector. Check "Preserve log" button, go to the "Network" tab in the inspector, click the "Go !" button in the website, right click the "message-list" in the Network Tab and hover on "Copy" and click to "Copy as cURL (bash)". Now go to the curlconverter, paste your code here. The header and cookies dictionary will appear, copy them and use in your codes.

  1. Open Perplexity.ai website. Sign out if you're signed in. Click F12 or Ctrl + Shift + I to open inspector. Check "Preserve log" button, go to the "Network" tab in the inspector, click the "Sign Up" button in the website, write a random email and click "Continue with Email" button, right click the "email" in the Network Tab and hover on "Copy" and click to "Copy as cURL (bash)". Now go to the curlconverter, paste your code here. The header and cookies dictionary will appear, copy them and use in your codes.

  1. Don't confuse the headers and cookies for emailnator and Perplexity.ai, look at How To Use to learn how to use them.

Thanks To

About

Unofficial API Wrapper for Perplexity.ai + Account Generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%