cannot import name 'AsyncWebCrawler' from 'crawl4ai'
Thank you so much for your contributions! Can you unify the sample code versions in the documentation? (https://crawl4ai.com/mkdocs) Have a 0.3.5 version, have 0.2.77 version, I am a little confusion.
The command from crawl4ai import AsyncWebCrawler works fine in version 0.3.5, but in version 0.2.77, it raises an error: ImportError: cannot import name 'AsyncWebCrawler' from 'crawl4ai'.
from crawl4ai import WebCrawlerworks fine in version 0.2.77,but 0.2.77,it raises an error:TypeError: 'NoneType' object is not callable
The code given in the examples in documentation(https://crawl4ai.com/mkdocs) has both versions, causing me a bit of confusion right now
Try renaming the script file.
@1933211129 Any version below 0.3.0 is a synchronous version of a library while recent release and changes to async follow 0.3.x. If you look at the code example, it is basically using the asynchronous version, so you can easily follow that one for the version. By the way, by next week, we're going to release 0.3.6.
However, to use the synchronous version, you must import from the relevant module, no longer from the main library. Here is a sample of that code.
from crawl4ai.web_crawler import WebCrawler
crawler = WebCrawler(verbose=True)
crawler.warmup()
result = crawler.run(url="https://www.nbcnews.com/business", only_text = True)
By the way, I strongly recommend you use the async version. We're not even sure if we want to maintain the sync version in the future. It's faster, use Playwright, not Selenium, and we're bringing a lot of features in that version.
Please do not hesitate. Let me know if you have any more questions.
@unclecode Thank you for your reply! I can currently use 'Playwright' to run normally.