█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

Crawlee for Python

भरोसेमंद crawlers बनाने के लिए Python की web scraping और browser automation लाइब्रेरी

Web Scraping & Crawlingओपन सोर्स
भाषा
Python
संक्षेप में

Crawlee for Python क्या है?

Crawlee for Python भरोसेमंद crawlers बनाने के लिए Python की web scraping और browser automation लाइब्रेरी. यह Data & Labeling टूल्स की Web Scraping & Crawling श्रेणी में आता है; ओपन सोर्स है और Python में लिखा गया है। शुरू करने के लिए: crawlee इंस्टॉल करें.

सारांश

Crawlee for Python, Apify की Crawlee लाइब्रेरी का Python वर्शन है। यह crawling और scraping का पूरा काम संभालती है: links को follow करना, data extract करना और उसे machine-readable formats में store करना। इससे आप उस plumbing के बजाय इस पर ध्यान दे सकते हैं कि आपको कौन सा data चाहिए।

यह उन Python developers के लिए बनी है जिन्हें बड़े पैमाने पर web data जुटाना होता है, जिसमें AI, LLMs और RAG pipelines के लिए data भी शामिल है। इसमें दो तरह के crawler मिलते हैं: HTML को BeautifulSoup से parse करने वाला HTTP-based crawler, और उन sites के लिए Playwright-based crawler जिन्हें client-side JavaScript चाहिए। इसकी default settings ऐसी tuned हैं कि crawlers आम bot protections से बचकर सामान्य यूज़र जैसे दिखें।

Web scraping और crawling की दुनिया में Crawlee एक single-purpose tool के बजाय पूरे framework के रूप में काम करता है। यह request queue, link enqueuing, retries और persistent storage खुद संभालता है, और जब defaults काफ़ी न हों तो विस्तृत configuration की सुविधा देता है। JavaScript projects के लिए TypeScript implementation भी उपलब्ध है।

यह क्या करता है

  • दो तरह के crawlers: तेज़ HTTP-based HTML scraping के लिए BeautifulSoupCrawler, और JavaScript-heavy sites के लिए PlaywrightCrawler
  • Default configuration से crawlers इंसानों जैसे दिखते हैं, जिससे आधुनिक bot protections द्वारा ब्लॉक होने की संभावना कम होती है
  • context.enqueue_links() से built-in link enqueuing, ताकि मिले हुए links को follow करते हुए site को crawl किया जा सके
  • context.push_data() के ज़रिए persistent storage, जो scraped data को स्थानीय storage/ directory में लिखता है
  • Crawlee CLI, जिसमें तैयार project templates हैं ताकि नया crawler जल्दी scaffold किया जा सके
  • Modular install: एक छोटा core package और साथ में वैकल्पिक extras जैसे beautifulsoup और all, ताकि dependencies कम रहें

शुरू करें

Crawlee, PyPI पर crawlee package के नाम से प्रकाशित है। इसे इंस्टॉल करें, Playwright सेट अप करें, फिर एक minimal crawler चलाएँ।

Crawlee इंस्टॉल करें

सभी features के साथ package इंस्टॉल करें, फिर Playwright के browser dependencies इंस्टॉल करें।

bashbash
python -m pip install 'crawlee[all]'
playwright install

इंस्टॉलेशन की पुष्टि करें

पुष्टि करें कि Crawlee import हो पा रहा है और उसका version print करें।

bashbash
python -c 'import crawlee; print(crawlee.__version__)'

CLI से project scaffold करें (वैकल्पिक)

सबसे तेज़ शुरुआत Crawlee CLI से होती है, जिसमें तैयार templates मिलते हैं। इसके लिए uv की ज़रूरत होती है।

bashbash
uvx 'crawlee[cli]' create my-crawler

एक minimal crawler लिखें

यह BeautifulSoupCrawler HTTP से pages लाता है, title extract करता है, data store करता है और links को follow करता है। एक run आपकी working directory में storage/ directory बनाता है।

pythonpython
import asyncio

from crawlee.crawlers import BeautifulSoupCrawler, BeautifulSoupCrawlingContext

async def main() -> None:
    crawler = BeautifulSoupCrawler(
        # Limit the crawl to max requests. Remove or increase it for crawling all links.
        max_requests_per_crawl=10,
    )

    # Define the default request handler, which will be called for every request.
    @crawler.router.default_handler
    async def request_handler(context: BeautifulSoupCrawlingContext) -> None:
        context.log.info(f'Processing {context.request.url} ...')

        # Extract data from the page.
        data = {
            'url': context.request.url,
            'title': context.soup.title.string if context.soup.title else None,
        }

        # Push the extracted data to the default dataset.
        await context.push_data(data)

        # Enqueue all links found on the page.
        await context.enqueue_links()

    # Run the crawler with the initial list of URLs.
    await crawler.run(['https://crawlee.dev'])

if __name__ == '__main__':
    asyncio.run(main())

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • AI, LLM और RAG pipelines के लिए web data जुटाना
  • HTTP-based BeautifulSoupCrawler का उपयोग करके static HTML pages से बड़े पैमाने पर structured data scrape करना
  • PlaywrightCrawler के ज़रिए असली browser की ज़रूरत वाली JavaScript-heavy sites को crawl करना
  • ऐसा site crawler बनाना जो links को follow करे और नतीजों को बाद में प्रोसेस करने के लिए स्थानीय storage में सहेजे

How Crawlee for Python compares

Crawlee for Python alongside other open-source web scraping & crawling tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Firecrawl★ 215kकिसी भी वेबसाइट को अपने LLM ऐप्स के लिए साफ़ Markdown या स्ट्रक्चर्ड JSON में बदलें
Agent Reach★ 117kपहले से कॉन्फ़िगर की गई वेब-एक्सेस लेयर, जो CLI एजेंट को उन साइटों के लिए रीडर देती है जहाँ उसकी पहुँच नहीं है
Scrapling★ 108kएडैप्टिव Python वेब स्क्रैपिंग, जो साइट में बदलाव के बावजूद काम करती रहे और anti-bot सिस्टम को बायपास करे
Crawl4AI★ 88.4kवेब पेजों को साफ़, LLM के लिए तैयार Markdown में बदलने वाला ओपन सोर्स वेब क्रॉलर
Scrapy★ 65.7kबड़े पैमाने पर वेबसाइट क्रॉल करने और संरचित डेटा निकालने के लिए एक Python फ़्रेमवर्क
changedetection.io★ 36.2kLLM-फ़िल्टर्ड अलर्ट के साथ सेल्फ-होस्टेड वेब पेज चेंज मॉनिटरिंग
ScrapeGraphAI★ 33kसादी अंग्रेज़ी के प्रॉम्प्ट से LLM और ग्राफ़ पाइपलाइन द्वारा संरचित वेब डेटा निकालें
Crawlee for Python★ 9.7kभरोसेमंद crawlers बनाने के लिए Python की web scraping और browser automation लाइब्रेरी