[Bug]: BestFirstCrawlingStrategy fetches a full batch past max_pages
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 74/100
Direzione di ricerca
Inizia dal metodo _arun_best_first di BestFirstCrawlingStrategy, nel ciclo che riempie ogni batch. Calcola batch_size = min(BATCH_SIZE, remaining) ma itera su range(BATCH_SIZE), quindi il ciclo dovrebbe usare batch_size. Esegui lo script di riproduzione con max_pages=12 e conferma che vengono recuperate solo 12 pagine. È completato quando il numero di recuperi corrisponde a max_pages e i test deep-crawl esistenti continuano a passare. La PR aperta #2246 usa lo stesso schema, quindi controllala per eventuali conflitti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
crawl4ai version
0.9.5 (same on 0.9.0)
Expected Behavior
BestFirstCrawlingStrategy with max_pages=N fetches about N pages: the last batch is cut to the remaining budget.
Current Behavior
_arun_best_first computes batch_size = min(BATCH_SIZE, remaining) but pops range(BATCH_SIZE) items, so the last batch is always 10 URLs. They are all fetched, and the results past the limit are dropped. With max_pages=12, 21 pages are fetched for 12 results (24 on 0.9.0).
Is this reproducible?
Yes
Code snippets
import asyncio
from aiohttp import web
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig
from crawl4ai.deep_crawling import BestFirstCrawlingStrategy
hits = []
async def handle(request):
hits.append(request.path)
links = "".join(f'<a href="/p{i}">p{i}</a>' for i in range(30)) if request.path == "/" else ""
return web.Response(text=f"<html><body>{links}<p>{'text ' * 200}</p></body></html>", content_type="text/html")
async def main():
app = web.Application()
app.router.add_get("/{tail:.*}", handle)
runner = web.AppRunner(app)
await runner.setup()
await web.TCPSite(runner, "127.0.0.1", 8766).start()
config = CrawlerRunConfig(deep_crawl_strategy=BestFirstCrawlingStrategy(max_depth=1, max_pages=12), stream=True)
async with AsyncWebCrawler() as crawler:
results = [r async for r in await crawler.arun("http://127.0.0.1:8766/", config=config)]
print("results:", len(results), "pages fetched:", len([h for h in hits if h != "/robots.txt"])) # 12 vs 21
await runner.cleanup()
asyncio.run(main())
Suggested fix
for _ in range(batch_size): in the batch-filling loop. The open PR #2246 (configurable batch_size) keeps the same pattern: it computes effective_batch_size but loops over range(self.batch_size).
- Lingua principale
- Python
- Stelle
- 85.4k
- Fork
- 8.9k
- Merge medio
- 5g 7h
- PR unite (30g)
- 23
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di unclecode/crawl4ai
-
[Bug]: Since 0.9.1, Linux launches chrome-headless-shell instead of ChromiumForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: CrawlerRunConfig.clone() drops fallback_fetch_function, so deep crawls never use itForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Docker memory guard reads host RAM when no container limit is set — cgroup v2 "max" defeats get_container_memory_percentForse già presa @Battleplus l’ha presa 54 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
unclecode/crawl4ai#2123 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: After a streamed deep crawl is stopped early, the next deep crawl returns only the start pageForse già presa @PiUnknown l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 12/100
unclecode/crawl4ai#2380 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: PDF URI links are silently discarded by PDFContentScrapingStrategy due to Links schema mismatchForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di unclecode/crawl4ai
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lidofinance/diffyscan#239 ·
I maintainer di solito rispondono entro 1 giorno
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsApertaarea: tools documentation good first issue ready for a contributor
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
eyalgolan/statecraft-israel#873 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
GET rooms API returns 500 due to nonexistent Room.is_active attributeForse già presa @Mars-60 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Add cover art to song rowsApertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
Harmony OPeNDAP SubSetter (HOSS) Geographic production rssmif16d 7 XYZ_PROV
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nasa/harmony-autotester#341 ·