Пример #1
0
        private string GetCryptedStepCheckFromUrl(string pageUrl)
        {
            var content          = WebHandler.DownloadContent(pageUrl, CookieContainer, CookieCollection);
            var cryptedStepCheck = new Regex(CryptedStepCheckPattern);

            return(cryptedStepCheck.Match(content).Groups[1].Value);
        }
Пример #2
0
        public ConfirmationPayment GetConfirmationPaymentInfo(string confirmationPaymentUrl)
        {
            var content = WebHandler.DownloadContent(confirmationPaymentUrl, CookieContainer, CookieCollection);

            //var xmlDocument = WebHandler.DownloadDocument(content);
            try
            {
                var regex     = new Regex("Payment ID(.*)<br>");
                var paymentId = Convert.ToInt64(regex.Match(content).Value.Replace("<br>", "").Replace("Payment ID:", ""));
                regex = new Regex("PostingID(.*)<i>");
                //content = xmlDocument.SelectSingleNode("//table[@id='postingInvoice']/tr[3]/td[2]").InnerXml;
                var postingId = Convert.ToInt64(regex.Match(content).Value.Replace("PostingID", "").Replace(":", "").Replace("<i>", ""));
                if (paymentId == 0 || postingId == 0)
                {
                    return new ConfirmationPayment()
                           {
                               Status = CraigslistPostingStatus.Error, ErrorMessage = confirmationPaymentUrl
                           }
                }
                ;

                return(new ConfirmationPayment()
                {
                    PaymentId = paymentId, PostingId = postingId, Status = CraigslistPostingStatus.Success, ErrorMessage = confirmationPaymentUrl
                });
            }
            catch (Exception ex)
            {
                return(new ConfirmationPayment()
                {
                    Status = CraigslistPostingStatus.Error, ErrorMessage = confirmationPaymentUrl
                });
            }
        }
Пример #3
0
        public string GetLocationPostUrl(string locationUrl)
        {
            var htmlDoc = new HtmlDocument();

            var content = WebHandler.DownloadContent(locationUrl);

            htmlDoc.LoadHtml(content);

            return(htmlDoc.DocumentNode.SelectSingleNode("//ul[@id='postlks']//li//a").Attributes["href"].Value);
        }
Пример #4
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);
        }
Пример #5
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);
        }