#[cfg(not(feature = "crawl"))]
fn main() {
eprintln!("the `crawl_github_docs` example requires the `crawl` feature");
}
#[cfg(feature = "crawl")]
use link_r::prelude::*;
#[cfg(feature = "crawl")]
use std::time::Duration;
#[cfg(feature = "crawl")]
#[tokio::main]
async fn main() -> link_r::Result<()> {
let parent = "https://github.com/abyo-software/s4/tree/main/docs";
let mut index = LinkIndex::in_memory()?;
let report = index
.update(parent)
.depth(3)
.scope(CrawlScope::SameHost) .require_path("/abyo-software/s4") .require_path("/main/docs") .index_path("/blob/main/docs") .accept_extension("md") .max_pages(200)
.min_delay(Duration::from_millis(400)) .run()
.await?;
println!(
"indexed {} docs ({} added, {} unchanged, {} pages crawled)",
index.len(),
report.added,
report.unchanged,
report.pages_seen()
);
for query in [
"deployment and configuration",
"security threat model",
"gpu benchmarks",
] {
println!("\nquery: {query:?}");
for (i, hit) in index.search(query, 3).await?.iter().enumerate() {
println!(" {:>2}. {:.3} {}", i + 1, hit.score, hit.url);
}
}
Ok(())
}