Skip to content

Instantly share code, notes, and snippets.

@Basicprogrammer10
Created October 19, 2023 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Basicprogrammer10/ec7fa943e5ae992a0fde3e1352a753f5 to your computer and use it in GitHub Desktop.
Save Basicprogrammer10/ec7fa943e5ae992a0fde3e1352a753f5 to your computer and use it in GitHub Desktop.
fn main() -> Result<()> {
(0..2800).par_bridge().progress_count(2800).for_each(|id| {
let address = format!("../download/file.php?id={id}");
let res = match ureq::get(&address).call() {
Ok(x) => x,
Err(..) => return,
};
if res.status() != 200 {
return;
}
let content = res.header("Content-Disposition").unwrap();
let filename = content.split("''").nth(1).unwrap();
let mut file = OpenOptions::new()
.write(true)
.create(true)
.open(format!("{OUT_DIR}/{id}-{}", filename))
.unwrap();
io::copy(&mut res.into_reader(), &mut file).unwrap();
});
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment