-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import asyncio | ||
|
||
from playwright.async_api import Page | ||
|
||
from parsera import ParseraScript | ||
from parsera.engine.model import GPT4oMiniModel | ||
|
||
EMAIL = "<YOUR-EMAIL>" | ||
PASSWORD = "<YOUR-PASSWORD>" | ||
|
||
|
||
async def get_parsera_credits(): | ||
model = GPT4oMiniModel() | ||
|
||
# Define the script to execute during the session creation | ||
async def initial_script(page: Page) -> Page: | ||
await page.goto("https://parsera.org/auth/sign-in") | ||
await page.wait_for_load_state("networkidle") | ||
await page.get_by_label("Email").fill(EMAIL) | ||
await page.get_by_label("Password").fill(PASSWORD) | ||
await page.get_by_role("button", name="Sign In", exact=True).click() | ||
await page.wait_for_selector("text=Playground") | ||
return page | ||
|
||
# This script is executed after the url is opened | ||
async def repeating_script(page: Page) -> Page: | ||
await page.wait_for_timeout(1000) # Wait one second for page to load | ||
return page | ||
|
||
parsera = ParseraScript(model=model, initial_script=initial_script) | ||
return await parsera.arun( | ||
url="https://parsera.org/app", | ||
elements={ | ||
"credits": "number of credits", | ||
}, | ||
playwright_script=repeating_script, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
result = asyncio.run(get_parsera_credits()) | ||
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "parsera" | ||
version = "0.1.6" | ||
version = "0.1.7" | ||
description = "Lightweight library for scraping web-sites with LLMs" | ||
authors = ["Mikhail Zanka <[email protected]>"] | ||
license = "GPL-2.0-or-later" | ||
|