
ktorrent
collect test data for scraping korean torrent sites.
Status
| No | site | url | status |
|:--:|:-------------:|:---------------------------:|:------:|
| 1 | ttobogo | https://ttobogo.net | O |
| 2 | torrentube | https://torrentube.to | O |
| 3 | tshare | https://tshare.org | O |
| 4 | torrentmobile | https://torrentmobile15.com | O |
| 5 | torrentview | https://torrentview28.com | O |
| 6 | torrentsir | https://torrentsir31.com | O |
| 7 | torrentj | https://torrentj32.com | O |
Example
```rust
use example::*;
use std::sync::{Arc, Mutex};
use std::error::Error;
const HOST_URL: &'static str = "https://torrentsir31.com/";
[tokio::main]
async fn main() -> Result<(), Box> {
run().await?;
Ok(())
}
pub async fn run() -> Result<(), Box> {
let searchwords = "동상이몽2";
let data = getdata(searchwords);
let mut tasks = vec![];
let r: Vec<(String, String)> = vec![];
let result = Arc::new(Mutex::new(r));
for d in data.await? {
let result = Arc::clone(&result);
tasks.push(tokio::spawn(async move {
let bbsdoc = getdoc(&d.1).await.unwrap();
let magnet = getdatabyclassname(
&bbsdoc, "list-group", "a", "href")[1];
let mut r = result.lock().unwrap();
r.push((d.0, magnet.tostring()));
}));
}
for task in tasks {
task.await?;
}
let p = &mut *result.lock().unwrap();
p.sort();
p.reverse();
printtable(p.to_vec());
Ok(())
}
pub async fn getdata(searchwords: &str) -> Result> {
let searchurl = format!("{}/bbs/search.php?search.php&stx={}", HOSTURL, searchwords);
let baseurl = format!("{}/bbs", HOSTURL);
let searchdoc = getdoc(&searchurl).await?;
let titles = getdatabytagname(&searchdoc, "b", "schword");
let urls = getdatabyclassname(&searchdoc, "media-heading", "a", "href");
let k: Vec = urls.iter().map(|x| format!("{}{}", baseurl, x.trimstartmatches(|c| c == '.'))).collect();
let data: Vec<(String, String)> = titles.intoiter().zip(k.intoiter()).collect();
Ok(data)
}
```
Output
