batman
This commit is contained in:
commit
0893ab3d7c
14 changed files with 2101 additions and 0 deletions
24
src/scrapers/twitter.rs
Normal file
24
src/scrapers/twitter.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use anyhow::{Context, Result, bail};
|
||||
use std::{path::PathBuf, process::Command};
|
||||
|
||||
pub fn scrape(url: &str) -> Result<PathBuf> {
|
||||
let tweet_id = url.split('/').next_back().unwrap();
|
||||
println!("Scraping tweet ID: {}", tweet_id);
|
||||
|
||||
let out = Command::new("python")
|
||||
.arg("scrape_user_tweet_contents.py")
|
||||
.arg("--tweet-ids")
|
||||
.arg(tweet_id)
|
||||
.output()
|
||||
.with_context(|| "Failed to execute tweet scraping command")?;
|
||||
println!("Output command: {:?}", out);
|
||||
|
||||
if PathBuf::from("scraped-tweets")
|
||||
.join(format!("tweet-{}.toml", tweet_id))
|
||||
.exists()
|
||||
{
|
||||
return Ok(PathBuf::from("scraped-tweets").join(format!("tweet-{}.toml", tweet_id)));
|
||||
}
|
||||
|
||||
bail!("Scraping failed for tweet: {}", url)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue