public List <Image> GetImagesOfVehicle(string subPageRaw, int maxImages) { string galleryRaw = Scrp.NodeCutter(subPageRaw, "<!-- Gallery -->", "</ul>"); string[] galleryRawImages = galleryRaw.Split(new string[] { "<li" }, StringSplitOptions.None); List <Image> images = new List <Image>(); string imUrl; int i = 1; foreach (string s in galleryRawImages) { if (i >= maxImages) { break; } try { i++; imUrl = Scrp.NodeCutter(s, "src=", "alt="); imUrl = imUrl.Replace("\"", ""); imUrl = imUrl.Replace("amp;", ""); if (imUrl.Substring(0, 1) == "/") { imUrl = imUrl.Remove(0, 1); } imUrl = URL + imUrl; imUrl = imUrl.Replace("&wmk=&pfdrid_c=true", ""); images.Add(new Image(imUrl)); } catch { continue; } } return(images); }
public string GetTextFromSubPageBasedOnPanelBodyDiv(string subpageRaw, string startNode, string endNode) { try { string desc = Scrp.NodeCutter(subpageRaw, startNode, endNode); desc = Scrp.NodeCutter(desc, "<div class=\"panel-body\">", "</div>"); return(desc); } catch { return(""); } }
public DateTime GetAuctionEndTime(string subpageRaw) { try { string endTimeRaw = Scrp.NodeCutter(subpageRaw, "data-seconds=", ">"); endTimeRaw = endTimeRaw.Replace("\"", ""); endTimeRaw = endTimeRaw.Replace("seconds=", ""); return(DateTime.Now.AddSeconds(Int32.Parse(endTimeRaw))); } catch { throw new System.Exception("Cannot get auction end time"); } }
public int GetExternalId(string carNode) { try { string idExt = Scrp.NodeCutter(carNode, "id\":\"", ","); idExt = idExt.Replace(":", ""); idExt = idExt.Replace("\"", ""); return(Convert.ToInt32(idExt)); } catch { throw new System.Exception("Cannot get externall ID"); } }
public Vehicle GetVehicleMainFromNode(string vehicleNode) { Vehicle vhc = new Vehicle(); vhc.Title = Scrp.NodeCutter(vehicleNode, "at\":\"", "\",\""); vhc.Url = URL + Scrp.NodeCutter(vehicleNode, "au\":\"", "\",\""); vhc.IdExternal = GetExternalId(vehicleNode); Image imMini = new Image(URL.Substring(0, URL.Length - 1) + Scrp.NodeCutter(vehicleNode, "is\":\"", "\",\"")); vhc.Images.Add(imMini); vhc.CompanyProvider = GetCompanyProviderDescription(vehicleNode); vhc.IsActive = true; vhc.IsArchived = false; return(vhc); }