Пример #1
0
    public static ZillowEstimate GetChart(string zillowWebServiceId, string zpid)
    {
        //http://www.zillow.com/howto/api/GetSearchResults.htm

        var z = new ZillowEstimate();
        // Construct the url
        // var zEstimate = new decimal();
        var url = String.Format("http://www.zillow.com/webservice/GetChart.htm?zws-id={0}&unit-type=percent&zpid={1}", zillowWebServiceId, zpid);

        // Make the HTTP request / get the response
        var Request  = (System.Net.HttpWebRequest)WebRequest.Create(url);
        var Response = (HttpWebResponse)Request.GetResponse();

        // Parse the HTTP response into an XML document
        XmlDocument xml = new XmlDocument();

        xml.Load(Response.GetResponseStream());
        XmlElement root = xml.DocumentElement;

        //Return Code
        z.ReturnCode        = int.Parse(root.SelectSingleNode("//message/code").InnerText);
        z.ReturnCodeMessage = root.SelectSingleNode("//message/text").InnerText;
        if (z.ReturnCode == 0)
        {
            z.Url           = root.SelectSingleNode("//response/url").InnerText;
            z.Graphsanddata = root.SelectSingleNode("//response/graphsanddata").InnerText;
        }
        Response.Close();

        return(z);
    }
        public static ZillowEstimate GetZestimate(string zillowWebServiceId, string Address, string ZipCode)
        {
            //http://www.zillow.com/howto/api/GetSearchResults.htm

            var z = new ZillowEstimate();

            var googleApiId = "AIzaSyBJTntA6I2kn3Y3wC17WECYAsLViTT8QSg";
            // Construct the url
            var url = String.Format("http://www.zillow.com/webservice/GetSearchResults.htm?zws-id={0}&address={1}&citystatezip={2}", zillowWebServiceId, Address, ZipCode);



            // Make the HTTP request / get the response
            var Request  = (System.Net.HttpWebRequest)WebRequest.Create(url);
            var Response = (HttpWebResponse)Request.GetResponse();

            // Parse the HTTP response into an XML document
            XmlDocument xml = new XmlDocument();

            xml.Load(Response.GetResponseStream());
            XmlElement root = xml.DocumentElement;

            //Return Code
            z.ReturnCode        = int.Parse(root.SelectSingleNode("//message/code").InnerText);
            z.ReturnCodeMessage = root.SelectSingleNode("//message/text").InnerText;

            if (z.ReturnCode == 0)
            {
                try
                {
                    z.ZillowId          = int.Parse(root.SelectSingleNode("//response/results/result/zpid").InnerText);
                    z.LinktoMap         = root.SelectSingleNode("//response/results/result/links/mapthishome").InnerText;
                    z.LinktoHomeDetails = root.SelectSingleNode("//response/results/result/links/homedetails").InnerText;
                    //z.LinktoGraphsAndData = root.SelectSingleNode("//response/results/result/links/graphsanddata").InnerText;
                    z.LinktoComparables         = root.SelectSingleNode("//response/results/result/links/comparables").InnerText;
                    z.Estimate                  = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/amount").InnerText);
                    z.LastUpdated               = DateTime.Parse(root.SelectSingleNode("//response/results/result/zestimate/last-updated").InnerText);
                    z.ValueChange               = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/valueChange").InnerText);
                    z.ValueChangeDurationInDays = int.Parse(root.SelectSingleNode("//response/results/result/zestimate/valueChange").Attributes["duration"].Value);
                    z.ValueRangeLow             = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/valuationRange/low").InnerText);
                    z.ValueRangeHigh            = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/valuationRange/high").InnerText);
                    z.Street    = root.SelectSingleNode("//response/results/result/address/street").InnerText;
                    z.City      = root.SelectSingleNode("//response/results/result/address/city").InnerText;
                    z.State     = root.SelectSingleNode("//response/results/result/address/state").InnerText;
                    z.ZipCode   = root.SelectSingleNode("//response/results/result/address/zipcode").InnerText;
                    z.Latitude  = decimal.Parse(root.SelectSingleNode("//response/results/result/address/latitude").InnerText);
                    z.Longitude = decimal.Parse(root.SelectSingleNode("//response/results/result/address/longitude").InnerText);
                    //url for google image
                    z.GoogleUrl = String.Format("https://maps.googleapis.com/maps/api/streetview?size=100x100&location={1},{2}&fov=90&heading=235&pitch=10&key={0}", googleApiId, z.Latitude, z.Longitude);
                }


                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
Пример #3
0
    public static ZillowEstimate GetZestimate(string zillowWebServiceId, string Address, string ZipCode)
    {
        //http://www.zillow.com/howto/api/GetSearchResults.htm

        var z = new ZillowEstimate();
        // Construct the url
        // var zEstimate = new decimal();
        var url = String.Format("http://www.zillow.com/webservice/GetSearchResults.htm?zws-id={0}&address={1}&citystatezip={2}", zillowWebServiceId, Address, ZipCode);


        // Make the HTTP request / get the response
        var Request  = (System.Net.HttpWebRequest)WebRequest.Create(url);
        var Response = (HttpWebResponse)Request.GetResponse();

        // Parse the HTTP response into an XML document
        XmlDocument xml = new XmlDocument();

        xml.Load(Response.GetResponseStream());
        XmlElement root = xml.DocumentElement;

        //Return Code
        z.ReturnCode        = int.Parse(root.SelectSingleNode("//message/code").InnerText);
        z.ReturnCodeMessage = root.SelectSingleNode("//message/text").InnerText;


        if (z.ReturnCode == 0)
        {
            z.ZillowId                  = int.Parse(root.SelectSingleNode("//response/results/result/zpid").InnerText);
            z.LinktoMap                 = root.SelectSingleNode("//response/results/result/links/mapthishome").InnerText;
            z.LinktoHomeDetails         = root.SelectSingleNode("//response/results/result/links/homedetails").InnerText;
            z.LinktoGraphsAndData       = root.SelectSingleNode("//response/results/result/links/graphsanddata").InnerText;
            z.LinktoComparables         = root.SelectSingleNode("//response/results/result/links/comparables").InnerText;
            z.Estimate                  = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/amount").InnerText);
            z.LastUpdated               = DateTime.Parse(root.SelectSingleNode("//response/results/result/zestimate/last-updated").InnerText);
            z.ValueChange               = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/valueChange").InnerText);
            z.ValueChangeDurationInDays = int.Parse(root.SelectSingleNode("//response/results/result/zestimate/valueChange").Attributes["duration"].Value);
            z.ValueRangeLow             = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/valuationRange/low").InnerText);
            z.ValueRangeHigh            = decimal.Parse(root.SelectSingleNode("//response/results/result/zestimate/valuationRange/high").InnerText);

            z.Street    = root.SelectSingleNode("//response/results/result/address/street").InnerText;
            z.City      = root.SelectSingleNode("//response/results/result/address/city").InnerText;
            z.State     = root.SelectSingleNode("//response/results/result/address/state").InnerText;
            z.ZipCode   = root.SelectSingleNode("//response/results/result/address/zipcode").InnerText;
            z.Latitude  = decimal.Parse(root.SelectSingleNode("//response/results/result/address/latitude").InnerText);
            z.Longitude = decimal.Parse(root.SelectSingleNode("//response/results/result/address/longitude").InnerText);
        }
        Response.Close();

        return(z);
    }
Пример #4
0
        public static ZillowEstimate ZillowGetValuationChart(string zillowWebServiceId, string zpid)
        {
            //http://www.zillow.com/webservice/GetChart.htm?zws-id=X1-ZWz1cs7xazgk5n_6msnx&unit-type=percent&zpid=56777343&width=300&height=150

            var z = new ZillowEstimate();
            // Construct the url
            //    var zEstimate = new decimal();
            var url = String.Format("http://www.zillow.com/webservice/GetChart.htm?zws-id={0}&zpid={1}&unit-type=dollar&width=600&height=300&chartDuration=5years", zillowWebServiceId, zpid);


            // Make the HTTP request / get the response
            var Request  = (System.Net.HttpWebRequest)WebRequest.Create(url);
            var Response = (HttpWebResponse)Request.GetResponse();

            // Parse the HTTP response into an XML document
            XmlDocument xml = new XmlDocument();

            xml.Load(Response.GetResponseStream());
            XmlElement root = xml.DocumentElement;

            //Return Code
            z.ReturnCode        = int.Parse(root.SelectSingleNode("//message/code").InnerText);
            z.ReturnCodeMessage = root.SelectSingleNode("//message/text").InnerText;

            //NoDataAvailable.png
            //C:\inetpub\DNN55\Website\DesktopModules\GIBS\FlexMLS\Images
            if (z.ReturnCode == 0)
            {
                z.ChartValuation = root.SelectSingleNode("//response/url").InnerText;

                var graphsanddata = root.SelectSingleNode("//response/results/result/links/graphsanddata");
                if (graphsanddata != null)
                {
                    z.ChartLink = root.SelectSingleNode("//response/graphsanddata").InnerText;
                }
                else
                {
                    z.ChartLink = "";
                }
            }
            else
            {
                z.ChartValuation = "~/DesktopModules/GIBS/FlexMLS/Images/NoDataAvailable.png";
                z.ChartLink      = "";
            }
            Response.Close();

            return(z);
        }
Пример #5
0
        public static DataTable ZillowGetComps(string zillowWebServiceId, string zpid)
        {
            //http://www.zillow.com/webservice/GetDeepComps.htm?zws-id=X1-ZWz1cs7xazgk5n_6msnx&zpid=2107292608&count=5

            var z = new ZillowEstimate();

            // Construct the url
            //    var zEstimate = new decimal();
            //http://www.zillow.com/webservice/GetComps.htm?zws-id=X1-ZWz1cs7xazgk5n_6msnx&zpid=55871386&count=5
            ////////////////////////////////////////////////////////////////////////////////////////////////////

            var url = String.Format("http://www.zillow.com/webservice/GetDeepComps.htm?zws-id={0}&zpid={1}&count=5", zillowWebServiceId, zpid);


            // Make the HTTP request / get the response
            var Request  = (System.Net.HttpWebRequest)WebRequest.Create(url);
            var Response = (HttpWebResponse)Request.GetResponse();

            // Parse the HTTP response into an XML document
            XmlDocument xml = new XmlDocument();

            xml.Load(Response.GetResponseStream());

            XmlElement root = xml.DocumentElement;

            //   root.read
            //Return Code
            z.ReturnCode        = int.Parse(root.SelectSingleNode("//message/code").InnerText);
            z.ReturnCodeMessage = root.SelectSingleNode("//message/text").InnerText;

            DataTable dt;

            ////   dt.ReadXmlSchema
            //   dt.ReadXmlSchema(
            //   dt.ReadXmlSchema(HttpContext.Current.Server.MapPath(".") + "\\DesktopModules\\GIBS\\FlexMLS\\ZillowSchemas\\GetComps.xsd");

            if (z.ReturnCode == 0)
            {
                //xml.GetElementsByTagName("comparables");
                XmlNodeList xmlnode;
                xmlnode = xml.GetElementsByTagName("comparables");


                //     xmlnode = doc.SelectSingleNode("/result/address");

                //       XmlNode props = doc.SelectSingleNode("/result/address");

                ////     XmlNode props = root.SelectSingleNode("/entry/m:properties");
                //     int i = 0;
                //     string str = "<br />";

                //     for (i = 0; i <= xmlnode.Count - 1; i++)
                //     {
                //         xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                //         str = xmlnode[i].ChildNodes.Item(0).InnerText.Trim() + " <br /> " + xmlnode[i].ChildNodes.Item(1).InnerText.Trim() + " <br /> " + xmlnode[i].ChildNodes.Item(2).InnerText.Trim() + "<br /><br />";
                //         lblZpid.Text += str.ToString();
                //       //  MessageBox.Show(str);
                //     }

                //   lblZpid.Text += "<br />" + xml.SelectSingleNode("//response/properties/comparables/comp").InnerText;

                dt = ConvertXmlNodeListToDataTable(xmlnode);

                //       GridView1.DataSource = dt;
                //       //   GridView1.DataMember = "result";
                //       GridView1.DataBind();

                Response.Close();
                return(dt);
            }

            else
            {
                dt = new DataTable("ResultTable");
                dt.Columns.Add("Result", typeof(string));

                DataRow dr = dt.NewRow();
                dr["Result"] = z.ReturnCodeMessage.ToString();
                dt.Rows.Add(dr);

                return(dt);
            }
        }