public AirbnbReader() { LicenseCheak.Cheak(); this.Init(); }
//{5}{0} - place //{6}{1} - price max ( &price_max={1} ) //{7}{2} - price min ( &price_min={2} ) //{8}{3} - place name //{0}{4} - cheakin yyyy-mm-dd ( &checkin={4} ) //{1}{5} - cheakout ( &checkout={5} ) //{9}{6} - roomtype //&room_types%5B%5D=Entire%20home%2Fapt //&room_types%5B%5D=Private%20room //&room_types%5B%5D=Hotel%20room //&room_types%5B%5D=Shared%20room //{2}{3}{4}{7} - per_page //{10}{8} - offset &items_offset=20 public List <Ad> GetAds(Tuple <string, string> place, DateTime cheakin, DateTime cheakout, double price_min, double price_max, List <RoomType> room_type) { List <Ad> rezalt = new List <Ad>(); complitLoad = false; var ready = false; string placetype = ""; foreach (var pt in room_type) { placetype += "&room_types%5B%5D=" + pt.Value; } bool multipage = false; bool load_all_page = false; int offset = 0; while (!load_all_page) { string url = string.Format(filterUrlApi, "&checkin=" + cheakin.ToString("yyyy-MM-dd"), "&checkout=" + cheakout.ToString("yyyy-MM-dd"), 20, 20, 20, place.Item1, "&price_max=" + price_max, "&price_min=" + price_min, place.Item2, placetype, "&items_offset=" + offset); complitLoad = false; ready = false; browser.Load(url); while (!complitLoad || !ready) { if (complitLoad) { string rez_str = rezaltObj as string; rez_str = Regex.Replace(rez_str, "<.*?>", String.Empty); JObject jObject = null; jObject = JObject.Parse(rez_str); foreach (var item_tab in jObject["explore_tabs"]) { foreach (var item_sec in item_tab["sections"]) { if (item_sec["listings"] != null) { if (int.Parse(item_sec["localized_listing_count"].ToString()) > 49) { multipage = true; } foreach (var item in item_sec["listings"]) { Ad ad_item = new Ad(); ad_item.url = string.Format(roomUrl, item["listing"]["id"]); ad_item.country = (string)item["listing"]["localized_city"]; ad_item.data = cheakin.ToString("yy-MM-dd") + " " + cheakout.ToString("yyyy-MM-dd"); ad_item.price = (string)item["pricing_quote"]["rate"]["amount"]; ad_item.type = (string)item["listing"]["space_type"]; ad_item.feedbeack = (string)item["listing"]["reviews_count"]; ad_item.host = string.Format("users/show/{0}", item["listing"]["user"]["id"]); rezalt.Add(ad_item); } } } if (item_tab["pagination_metadata"]["has_next_page"].ToString() == "false") { load_all_page = true; } else { if (multipage) { if (item_tab["pagination_metadata"]["items_offset"] != null) { offset = int.Parse(item_tab["pagination_metadata"]["items_offset"].ToString()); } else { load_all_page = true; } } } } ready = true; complitLoad = true; } else { Thread.Sleep(50); } } } if (LicenseCheak.IsTrialCheak()) { rezalt = rezalt.Take(10).ToList(); } return(rezalt); }