|
|
@@ -27,18 +27,6 @@ struct Auction {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-fn main() {
|
|
|
- // let url = "http://www.egun.de/market/list_items.php?mode=qry&query=g36&plusdescr=off&plusdescr=on&wheremode=and&ewb=1&status=&minprice=&maxprice=&type=0&nick=&country_id=&zip=&int=0&order=ends&asdes=asc";
|
|
|
- let url = "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&wheremode=and&query=sniper&quick=1";
|
|
|
-
|
|
|
- // dbg!(parse_url(url));
|
|
|
-
|
|
|
- // write out the file
|
|
|
- let writer = BufWriter::new(File::create("db.json").unwrap());
|
|
|
- serde_json::to_writer_pretty(writer, &parse_url(url)).unwrap();
|
|
|
-}
|
|
|
-
|
|
|
fn date_to_gcal(date: DateTime<Local>) -> String {
|
|
|
format!("{}",
|
|
|
date.format("%Y%m%dT%H%M00/%Y%m%dT%H%M00")
|
|
|
@@ -115,6 +103,19 @@ fn parse_url(url: &str) -> Vec<Auction> {
|
|
|
// println!("PRICE\t{:?}", prices);
|
|
|
}
|
|
|
|
|
|
+ if let Some(url) = node
|
|
|
+ .children().into_iter()
|
|
|
+ .filter(|x| x.name() == Some("td"))
|
|
|
+ .filter(|x| x.attr("align") == Some("LEFT"))
|
|
|
+ .flat_map(|x| x.children())
|
|
|
+ .filter(|x| x.name() == Some("a"))
|
|
|
+ .map(|x| x.attr("href"))
|
|
|
+ .filter_map(|x| x)
|
|
|
+ .collect::<Vec<_>>().get(0) {
|
|
|
+ // println!("URL\t{:?}", url);
|
|
|
+ auction.url = format!("http://egun.de/market/{}", url);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if let Some(remaining) = parse_end_date(
|
|
|
&node
|
|
|
@@ -128,7 +129,7 @@ fn parse_url(url: &str) -> Vec<Auction> {
|
|
|
.join(" ")
|
|
|
){
|
|
|
// dbg!(&t_remaining.children());
|
|
|
- auction.gcal = date_to_gcal(remaining);
|
|
|
+ auction.gcal = format!("http://www.google.com/calendar/event?action=TEMPLATE&dates={}&text={}&location=&details=", date_to_gcal(remaining), auction.desc);
|
|
|
auction.timestamp = remaining.timestamp();
|
|
|
// println!("ENDS\t{:?}", date_to_gcal(remaining));
|
|
|
|
|
|
@@ -146,3 +147,13 @@ fn parse_url(url: &str) -> Vec<Auction> {
|
|
|
|
|
|
auctions
|
|
|
}
|
|
|
+fn main() {
|
|
|
+ // let url = "http://www.egun.de/market/list_items.php?mode=qry&query=g36&plusdescr=off&plusdescr=on&wheremode=and&ewb=1&status=&minprice=&maxprice=&type=0&nick=&country_id=&zip=&int=0&order=ends&asdes=asc";
|
|
|
+ let url = "http://www.egun.de/market/list_items.php?mode=qry&plusdescr=off&wheremode=and&query=sniper&quick=1";
|
|
|
+
|
|
|
+ // dbg!(parse_url(url));
|
|
|
+
|
|
|
+ // write out the file
|
|
|
+ let writer = BufWriter::new(File::create("db.json").unwrap());
|
|
|
+ serde_json::to_writer_pretty(writer, &parse_url(url)).unwrap();
|
|
|
+}
|