11using System . CommandLine ;
2- using System . Diagnostics . CodeAnalysis ;
32
43namespace Firecrawl . Cli . Commands ;
54
@@ -21,7 +20,7 @@ public CrawlCommand() : base(name: "crawl", description: "Crawl a url and saves
2120
2221 var limit = new Option < int > (
2322 name : "limit" ,
24- getDefaultValue : ( ) => 10 ,
23+ getDefaultValue : ( ) => 5 ,
2524 description : "Limit of pages to crawl" ) ;
2625 AddOption ( limit ) ;
2726
@@ -67,18 +66,8 @@ private static async Task HandleAsync(
6766
6867 Console . WriteLine ( $ "JobId: { response . JobId } ") ;
6968
70- GetCrawlStatusResponse ? statusResponse = null ;
71- while ( true )
72- {
73- await Task . Delay ( TimeSpan . FromSeconds ( 5 ) ) . ConfigureAwait ( false ) ;
74-
75- statusResponse = await api . Crawl . GetCrawlStatusAsync (
76- jobId : response . JobId ! ) . ConfigureAwait ( false ) ;
77- if ( statusResponse . Status == "completed" )
78- {
79- break ;
80- }
81- }
69+ var jobResponse = await api . Crawl . WaitJobAsync (
70+ jobId : response . JobId ! ) . ConfigureAwait ( false ) ;
8271
8372 if ( string . IsNullOrWhiteSpace ( outputPath ) )
8473 {
@@ -88,7 +77,7 @@ private static async Task HandleAsync(
8877 Directory . CreateDirectory ( outputPath ) ;
8978
9079 var index = 0 ;
91- foreach ( var data in statusResponse . Data ?? [ ] )
80+ foreach ( var data in jobResponse . Data ?? [ ] )
9281 {
9382 var name = string . IsNullOrWhiteSpace ( data . Metadata ? . SourceURL )
9483 ? $ "output{ ++ index } .md"
@@ -115,7 +104,7 @@ public static string ConvertUrlToFilename(string url)
115104 . Replace ( "www." , string . Empty , StringComparison . OrdinalIgnoreCase ) ;
116105
117106 // Replace invalid filename characters with '_'
118- foreach ( char c in Path . GetInvalidFileNameChars ( ) )
107+ foreach ( var c in Path . GetInvalidFileNameChars ( ) )
119108 {
120109 url = url . Replace ( c , '_' ) ;
121110 }
0 commit comments