Spaces:
Runtime error
Runtime error
File size: 605 Bytes
b4ccc57 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import asyncio
from crawl4ai import *
from urllib.parse import urlparse
url = url = input("Enter the website URL: ").strip()
async def main():
async with AsyncWebCrawler() as crawler:
result = await crawler.arun(
url=url,
)
print(result.markdown)
domain = urlparse(url).netloc.replace("www.", "")
filename = f"{domain}.txt"
with open(filename, "w", encoding="utf-8") as f:
f.write(result.markdown)
print(f"\n✅ Scraped content saved to '{filename}'")
if __name__ == "__main__":
asyncio.run(main()) |