-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transformations): add spider_transformation crate
- Loading branch information
Showing
24 changed files
with
8,527 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//! `cargo run --example transform_markdown --features="spider/sync spider_utils/transformations"` | ||
extern crate spider; | ||
|
||
use spider::tokio; | ||
use spider::website::Website; | ||
use spider_utils::spider_transformations::transformation::content::{ | ||
transform_content, ReturnFormat, TransformConfig, | ||
}; | ||
use tokio::io::AsyncWriteExt; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let mut website: Website = Website::new("https://rsseau.fr"); | ||
let mut rx2: tokio::sync::broadcast::Receiver<spider::page::Page> = | ||
website.subscribe(0).unwrap(); | ||
let mut stdout = tokio::io::stdout(); | ||
|
||
let mut conf = TransformConfig::default(); | ||
conf.return_format = ReturnFormat::Markdown; | ||
|
||
let join_handle = tokio::spawn(async move { | ||
while let Ok(res) = rx2.recv().await { | ||
let markup = transform_content(&res, &conf, &None, &None); | ||
|
||
let _ = stdout | ||
.write_all(format!("- {}\n {}\n", res.get_url(), markup).as_bytes()) | ||
.await; | ||
} | ||
stdout | ||
}); | ||
|
||
let start = std::time::Instant::now(); | ||
website.crawl().await; | ||
website.unsubscribe(); | ||
let duration = start.elapsed(); | ||
let mut stdout = join_handle.await.unwrap(); | ||
|
||
let _ = stdout | ||
.write_all( | ||
format!( | ||
"Time elapsed in website.crawl() is: {:?} for total pages: {:?}", | ||
duration, | ||
website.get_links().len() | ||
) | ||
.as_bytes(), | ||
) | ||
.await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "spider" | ||
version = "2.5.5" | ||
version = "2.6.2" | ||
authors = [ | ||
"j-mendez <jeff@spider.cloud>" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "spider_cli" | ||
version = "2.5.5" | ||
version = "2.6.2" | ||
authors = [ | ||
"j-mendez <jeff@spider.cloud>" | ||
] | ||
|
Oops, something went wrong.