Пример #1
0
        public List <SubLocationChoosing> GetSubLocationList(string subLocationChoosingUrl)
        {
            var list          = new List <SubLocationChoosing>();
            var xmlDocument   = WebHandler.DownloadDocument(WebHandler.DownloadContent(subLocationChoosingUrl, CookieContainer, CookieCollection));
            var locationNodes = xmlDocument.SelectNodes("//form/blockquote/label");

            if (locationNodes != null)
            {
                foreach (XmlNode node in locationNodes)
                {
                    var location = new SubLocationChoosing();
                    location.Value = Convert.ToInt32(WebHandler.GetString(node, "./input/@value", null, null, true));
                    location.Name  = node.InnerText.Trim();

                    list.Add(location);
                }
            }

            return(list);
        }
Пример #2
0
        public AdsPosting PreviewPosting(string previewUrl, VehicleInfo vehicle)
        {
            var post = new AdsPosting()
            {
                //Location = dealer.CraigslistSetting.City,
                //SubLocation = dealer.CraigslistSetting.Location,
                Type     = "for sale / wanted",
                Category = "cars & trucks - by dealer",
                //SpecificLocation = dealer.CraigslistSetting.SpecificLocation,
                Title        = String.Format("{0} {1} {2} {3}", vehicle.ModelYear, vehicle.Make, vehicle.Model, vehicle.Trim),
                SalePrice    = vehicle.SalePrice,
                Vin          = vehicle.Vin,
                Year         = Convert.ToInt32(vehicle.ModelYear),
                Make         = vehicle.Make,
                Model        = vehicle.Model,
                Odometer     = Convert.ToInt64(vehicle.Mileage),
                Transmission = String.Format("{0} Transmission", vehicle.Tranmission),
                Body         = GeneratePostingBody(vehicle),
                Note         = "do NOT contact me with unsolicited"
            };

            var xmlDocument = WebHandler.DownloadDocument(WebHandler.DownloadContent(previewUrl, CookieContainer, CookieCollection));
            var imageNodes  = xmlDocument.SelectNodes("//div[@id='thumbs']/a");

            if (imageNodes != null)
            {
                var images = new List <string>();
                foreach (XmlNode node in imageNodes)
                {
                    images.Add(node.Attributes["href"].Value);
                }
                post.Images = images;
            }

            return(post);
        }