mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
fix fetching
This commit is contained in:
1 parent
3e903972b2
commit
68e2c8e67c
2 files changed
+13
-6
No files matched your search
@@ -14,7 +14,7 @@ pub struct GetIndexPageScriptArgs<'a> {
|
||||
|
||||
/// Get javascript that we'll need for client crypto purposes.
|
||||
pub async fn get_index_page_script(args: GetIndexPageScriptArgs<'_>) -> Result<String, GrokError> {
|
||||
let script_url = format!("{}/{}", INDEX_URL, args.script_url);
|
||||
let script_url = get_script_url(args.script_url);
|
||||
|
||||
let builder = args.client.get(script_url)
|
||||
.header("User-Agent", FIREFOX_143_MAC_USER_AGENT)
|
||||
@@ -33,12 +33,17 @@ pub async fn get_index_page_script(args: GetIndexPageScriptArgs<'_>) -> Result<S
|
||||
.map_err(|err| GrokClientError::WreqClientError(err))?;
|
||||
|
||||
// TODO: Cloudflare handling.
|
||||
|
||||
let body = response.text()
|
||||
.await
|
||||
.map_err(|err| GrokClientError::WreqClientError(err))?;
|
||||
|
||||
println!("Response body: {}", body);
|
||||
|
||||
Ok(body)
|
||||
}
|
||||
|
||||
fn get_script_url(script_path: &str) -> String {
|
||||
if script_path.starts_with("/") {
|
||||
format!("{}{}", INDEX_URL, script_path)
|
||||
} else {
|
||||
format!("{}/{}", INDEX_URL, script_path)
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
#[ignore] // manually test
|
||||
async fn test() -> AnyhowResult<()> {
|
||||
//setup_test_logging(LevelFilter::Trace);
|
||||
|
||||
|
||||
let cookie = get_test_cookies()?;
|
||||
|
||||
let index = get_index(GetIndexPageArgs {
|
||||
@@ -69,7 +69,9 @@ mod tests {
|
||||
}).await?;
|
||||
|
||||
for (k, v) in scripts.iter() {
|
||||
println!("{}: {}\n\n", k, v);
|
||||
let mut body = v.to_string();
|
||||
body.truncate(100);
|
||||
println!("{}: {}\n\n", k, body);
|
||||
}
|
||||
|
||||
assert_eq!(1, 2);
|
||||
|
||||
Reference in new issue
Block a user