Skip to content

Commit

Permalink
Fix: [Errno 36] File name too long
Browse files Browse the repository at this point in the history
  • Loading branch information
hlohaus committed Jan 3, 2025
1 parent 486e9a9 commit 1b30651
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion g4f/tools/web_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def fetch_and_scrape(session: ClientSession, url: str, max_words: int = No
bucket_dir: Path = Path(get_cookies_dir()) / ".scrape_cache" / "fetch_and_scrape"
bucket_dir.mkdir(parents=True, exist_ok=True)
md5_hash = hashlib.md5(url.encode()).hexdigest()
cache_file = bucket_dir / f"{url.split('?')[0].split('//')[1].replace('/', '+')}.{datetime.date.today()}.{md5_hash}.txt"
cache_file = bucket_dir / f"{url.split('?')[0].split('//')[1].replace('/', '+')[:16]}.{datetime.date.today()}.{md5_hash}.txt"
if cache_file.exists():
return cache_file.read_text()
async with session.get(url) as response:
Expand Down

0 comments on commit 1b30651

Please sign in to comment.