updating for base64
This commit is contained in:
parent
f42e770a10
commit
82929fd0fc
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3673,6 +3673,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
name = "surreal_spider"
|
name = "surreal_spider"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base64 0.22.1",
|
||||||
"html5ever 0.29.0",
|
"html5ever 0.29.0",
|
||||||
"minio",
|
"minio",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
base64 = "0.22.1"
|
||||||
html5ever = "0.29"
|
html5ever = "0.29"
|
||||||
# minio = "0.1.0"
|
# minio = "0.1.0"
|
||||||
minio = {git="https://github.com/minio/minio-rs.git", rev = "c28f576"}
|
minio = {git="https://github.com/minio/minio-rs.git", rev = "c28f576"}
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -41,17 +41,17 @@ async fn main() {
|
|||||||
surreal_username: "root",
|
surreal_username: "root",
|
||||||
surreal_password: "root",
|
surreal_password: "root",
|
||||||
surreal_ns: "test",
|
surreal_ns: "test",
|
||||||
surreal_db: "custom-engine-v2",
|
surreal_db: "b64v1",
|
||||||
s3_bucket: "custom-engine-v2",
|
s3_bucket: "b64v1",
|
||||||
s3_url: "http://localhost:9000",
|
s3_url: "http://localhost:9000",
|
||||||
s3_access_key: "0zv7GbLQsw4ZI8TclMps",
|
s3_access_key: "8UO76z8wCs9DnpxSbQUY",
|
||||||
s3_secret_key: "5dB7QkGFw7fYbUJ5LpHk2GbWR7Bl710HlRz4NbzB",
|
s3_secret_key: "xwKVMpf2jzgprsdo85Dvo74UmO84y0aRrAUorYY5",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Would probably take these in as parameters from a cli
|
// Would probably take these in as parameters from a cli
|
||||||
let starting_url = "https://en.wikipedia.org/";
|
let starting_url = "https://en.wikipedia.org/";
|
||||||
// When getting uncrawled pages, name must contain this variable. "" will effectively get ignored.
|
// When getting uncrawled pages, name must contain this variable. "" will effectively get ignored.
|
||||||
let crawl_filter = "https://en.wikipedia.org/";
|
let crawl_filter = "wikipedia.org/";
|
||||||
let budget = 50;
|
let budget = 50;
|
||||||
let mut crawled = 0;
|
let mut crawled = 0;
|
||||||
|
|
||||||
|
@ -43,9 +43,14 @@ impl S3 {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip_all)]
|
||||||
pub async fn store(&self, data: &str, name: &Url) {
|
pub async fn store(&self, data: &str, name: &Url) {
|
||||||
if let Some(domain) = name.domain() {
|
if let Some(domain) = name.to_string().split('#').collect::<Vec<&str>>().get(0) {
|
||||||
let filename = domain.to_string() + name.path();
|
use base64::prelude::*;
|
||||||
|
// FIXME can still get unsupported characters, _ I think
|
||||||
|
let filename = BASE64_URL_SAFE.encode(domain);
|
||||||
|
|
||||||
|
trace!("Filename: {filename} from {domain}");
|
||||||
|
|
||||||
let _ = &self
|
let _ = &self
|
||||||
.client
|
.client
|
||||||
|
Loading…
Reference in New Issue
Block a user