Fixing 1337x failures to continue.
This commit is contained in:
parent
6dcc7d5d07
commit
83e5c61c2f
|
@ -48,24 +48,24 @@ fn skytorrents() {
|
||||||
let html = fetch_html(page);
|
let html = fetch_html(page);
|
||||||
let document = Document::from(&html[..]);
|
let document = Document::from(&html[..]);
|
||||||
for row in document.find(Attr("id", "results").descendant(Name("tr"))) {
|
for row in document.find(Attr("id", "results").descendant(Name("tr"))) {
|
||||||
let info_hash: String = row
|
let info_hash_td = match row.find(Name("td").descendant(Name("a"))).nth(2) {
|
||||||
.find(Name("td").descendant(Name("a")))
|
Some(t) => t,
|
||||||
.nth(2)
|
None => continue,
|
||||||
.unwrap()
|
};
|
||||||
.attr("href")
|
let info_hash = match info_hash_td.attr("href") {
|
||||||
.unwrap()
|
Some(t) => t.chars().skip(20).take(40).collect(),
|
||||||
.chars()
|
None => continue,
|
||||||
.skip(20)
|
};
|
||||||
.take(40)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let name = row
|
let name = match row.find(Name("td").descendant(Name("a"))).nth(0) {
|
||||||
.find(Name("td").descendant(Name("a")))
|
Some(t) => t.text(),
|
||||||
.nth(0)
|
None => continue,
|
||||||
.unwrap()
|
};
|
||||||
.text();
|
|
||||||
|
|
||||||
let size = row.find(Name("td")).nth(1).unwrap().text();
|
let size = match row.find(Name("td")).nth(1) {
|
||||||
|
Some(t) => t.text(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
let size_bytes = convert_to_bytes(size);
|
let size_bytes = convert_to_bytes(size);
|
||||||
|
|
||||||
// simulate a start and scraped date
|
// simulate a start and scraped date
|
||||||
|
@ -74,9 +74,14 @@ fn skytorrents() {
|
||||||
.expect("Time went backwards")
|
.expect("Time went backwards")
|
||||||
.as_secs();
|
.as_secs();
|
||||||
|
|
||||||
let seeders = row.find(Name("td")).nth(4).unwrap().text().replace(",", "");
|
let seeders = match row.find(Name("td")).nth(4) {
|
||||||
let leechers = row.find(Name("td")).nth(5).unwrap().text().replace(",", "");
|
Some(t) => t.text().replace(",", ""),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
let leechers = match row.find(Name("td")).nth(5) {
|
||||||
|
Some(t) => t.text().replace(",", ""),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
// infohash;name;size_bytes;created_unix;seeders;leechers;completed;scraped_date
|
// infohash;name;size_bytes;created_unix;seeders;leechers;completed;scraped_date
|
||||||
|
|
||||||
let add_line = [
|
let add_line = [
|
||||||
|
@ -131,45 +136,58 @@ fn leetx() {
|
||||||
.descendant(Name("tbody"))
|
.descendant(Name("tbody"))
|
||||||
.descendant(Name("tr")),
|
.descendant(Name("tr")),
|
||||||
) {
|
) {
|
||||||
let detail_page_url = row
|
let detail_page_url_col = match row.find(Class("coll-1")).nth(0) {
|
||||||
.find(Class("coll-1"))
|
Some(t) => t,
|
||||||
.nth(0)
|
None => continue,
|
||||||
.unwrap()
|
};
|
||||||
.find(Name("a"))
|
let detail_page_url_name = match detail_page_url_col.find(Name("a")).nth(1) {
|
||||||
.nth(1)
|
Some(t) => t,
|
||||||
.unwrap()
|
None => continue,
|
||||||
.attr("href")
|
};
|
||||||
.unwrap();
|
let detail_page_url_href = match detail_page_url_name.attr("href") {
|
||||||
let detail_full_url = format!("{}{}", base_url, detail_page_url);
|
Some(t) => t,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let detail_full_url = format!("{}{}", base_url, detail_page_url_href);
|
||||||
println!("Fetching page {}", detail_full_url);
|
println!("Fetching page {}", detail_full_url);
|
||||||
let detail_html = fetch_html(&detail_full_url);
|
let detail_html = fetch_html(&detail_full_url);
|
||||||
let detail_document = Document::from(&detail_html[..]);
|
let detail_document = Document::from(&detail_html[..]);
|
||||||
let info_hash = detail_document
|
let info_hash = match detail_document
|
||||||
.find(Class("infohash-box").descendant(Name("span")))
|
.find(Class("infohash-box").descendant(Name("span")))
|
||||||
.nth(0)
|
.nth(0)
|
||||||
.unwrap()
|
{
|
||||||
.text()
|
Some(t) => t.text().to_lowercase(),
|
||||||
.to_lowercase();
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let name_col = match row.find(Class("coll-1")).nth(0) {
|
||||||
|
Some(t) => t,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
let name = match name_col.find(Name("a")).nth(1) {
|
||||||
|
Some(t) => t.text(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let seeders = match row.find(Class("coll-2")).nth(0) {
|
||||||
|
Some(t) => t.text(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
let leechers = match row.find(Class("coll-3")).nth(0) {
|
||||||
|
Some(t) => t.text(),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let size_col = match row.find(Class("coll-4")).nth(0) {
|
||||||
|
Some(t) => t,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
let size = match size_col.children().nth(0) {
|
||||||
|
Some(t) => t.text().replace(",", ""),
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
|
||||||
let name = row
|
|
||||||
.find(Class("coll-1"))
|
|
||||||
.nth(0)
|
|
||||||
.unwrap()
|
|
||||||
.find(Name("a"))
|
|
||||||
.nth(1)
|
|
||||||
.unwrap()
|
|
||||||
.text();
|
|
||||||
let seeders = row.find(Class("coll-2")).nth(0).unwrap().text();
|
|
||||||
let leechers = row.find(Class("coll-3")).nth(0).unwrap().text();
|
|
||||||
let size = row
|
|
||||||
.find(Class("coll-4"))
|
|
||||||
.nth(0)
|
|
||||||
.unwrap()
|
|
||||||
.children()
|
|
||||||
.nth(0)
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.replace(",", "");;
|
|
||||||
let size_bytes = convert_to_bytes(size);
|
let size_bytes = convert_to_bytes(size);
|
||||||
|
|
||||||
let created_unix = SystemTime::now()
|
let created_unix = SystemTime::now()
|
||||||
|
|
Loading…
Reference in New Issue