diff options
| author | Fuwn <[email protected]> | 2024-06-23 20:39:39 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-23 20:39:39 -0700 |
| commit | d3ecb5376aa6295a032bf3886f93c3f5b4b4b1e4 (patch) | |
| tree | 72d460992fb9b46a41881663c19ac6331f735226 /src/modules/web.rs | |
| parent | feat(robots.txt): disallow ai (diff) | |
| download | locus-d3ecb5376aa6295a032bf3886f93c3f5b4b4b1e4.tar.xz locus-d3ecb5376aa6295a032bf3886f93c3f5b4b4b1e4.zip | |
feat(technology): C++
Diffstat (limited to 'src/modules/web.rs')
| -rw-r--r-- | src/modules/web.rs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/modules/web.rs b/src/modules/web.rs index df13058..1be6f48 100644 --- a/src/modules/web.rs +++ b/src/modules/web.rs @@ -49,7 +49,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v )) else { return error("The URL you provided is invalid.", &context); }; - let mut contents = vec![format!("=> {url} {url}")]; + let mut contents = vec![format!("=> {url} {url}\n")]; let website = if let Ok(website) = reqwest::get(url.clone()).await { if let Ok(text) = website.text().await { text @@ -86,8 +86,22 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v }; } + if let Some(id) = queries.get("class") { + nodes = if let Some(element) = + dom.get_elements_by_class_name(id.as_str()).nth(0) + { + if let Some(children) = element.get(parser).unwrap().children() { + children.all(parser).iter().peekable() + } else { + nodes + } + } else { + nodes + }; + } + while let Some(element) = nodes.next() { - let mut text = String::new(); + let text = String::new(); let () = element.as_tag().map_or((), |tag| { match tag.name().as_utf8_str().to_string().as_str() { @@ -141,7 +155,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v "h3" => { contents.push(format!("\n### {}\n\n", tag.inner_text(parser))); } - "pre" | "code" => { + "pre" => { contents.push(format!("```\n{}```\n", tag.inner_text(parser))); } "blockquote" => { @@ -166,13 +180,13 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v "html" | "head" | "script" | "link" | "title" | "body" | "ul" | "style" => {} _ => { - text = tag.inner_text(parser).to_string(); + // text = tag.inner_text(parser).to_string(); - if !(text.contains("Proxy Information") - || text.contains("Proxied content from")) - { - contents.push(format!("{text}\n\n")); - } + // if !(text.contains("Proxy Information") + // || text.contains("Proxied content from")) + // { + // contents.push(format!("{text}\n\n")); + // } } } }); |