Skip to content

feat(docloaders): undetected-playwright #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ examples/graph_examples/ScrapeGraphAI_generated_graph
examples/**/result.csv
examples/**/result.json
main.py


.idea
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies = [
"playwright==1.43.0",
"google==3.0.0",
"yahoo-search-py==0.3",
"undetected-playwright==0.3.0",
]

license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ langchain-aws==0.1.2
langchain-anthropic==0.1.11
yahoo-search-py==0.3
pypdf==4.2.0
undetected-playwright==0.3.0
5 changes: 4 additions & 1 deletion scrapegraphai/docloaders/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async def ascrape_playwright(self, url: str) -> str:

"""
from playwright.async_api import async_playwright
from undetected_playwright import Malenia

logger.info("Starting scraping...")
results = ""
Expand All @@ -77,7 +78,9 @@ async def ascrape_playwright(self, url: str) -> str:
headless=self.headless, proxy=self.proxy, **self.browser_config
)
try:
page = await browser.new_page()
context = await browser.new_context()
await Malenia.apply_stealth(context)
page = await context.new_page()
await page.goto(url)
results = await page.content() # Simply get the HTML content
logger.info("Content scraped")
Expand Down
3 changes: 3 additions & 0 deletions scrapegraphai/helpers/models_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
},
"gemini": {
"gemini-pro": 128000,
"gemini-1.5-flash-latest":128000,
"gemini-1.5-pro-latest":128000,
"models/embedding-001": 2048
},

Expand All @@ -49,6 +51,7 @@
"dbrx": 32768,
"dbrx:instruct": 32768,
"nous-hermes2:34b": 4096,
"orca-mini": 2048,
# embedding models
"nomic-embed-text": 8192,
"snowflake-arctic-embed:335m": 8192,
Expand Down
Loading