예제 #1
0
        void GetNISTGasData(string casNo)
        {
            List<NistFormationEnthlpyOrEntropy> enthalpies = new List<NistFormationEnthlpyOrEntropy>();
            List<NistFormationEnthlpyOrEntropy> entropies = new List<NistFormationEnthlpyOrEntropy>();
            List<NistCP> cps = new List<NistCP>();
            string url = "http://webbook.nist.gov/cgi/cbook.cgi?ID=C" + casNo.Replace("-", string.Empty) + "&Units=SI&Mask=1#Thermo-Gas";
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
            System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.StringReader reader = new System.IO.StringReader(new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd());
            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.Load(reader);
            foreach (HtmlAgilityPack.HtmlNode bodyNode in document.DocumentNode.ChildNodes.Nodes())
            {
                if (bodyNode.Name == "body")
                {
                    bool NextTableShomate = false;
                    foreach (HtmlAgilityPack.HtmlNode tableNode in bodyNode.ChildNodes)
                    {
                        if (tableNode.InnerText == "Gas Phase Heat Capacity (Shomate Equation)")
                        {
                            NextTableShomate = true;
                        }
                        if (tableNode.Name == "table")
                        {
                            foreach (HtmlAgilityPack.HtmlNode rowNode in tableNode.ChildNodes)
                            {
                                if (rowNode.Name == "tr")
                                {
                                    if (rowNode.ChildNodes.Count == 6)
                                    {
                                        if (rowNode.ChildNodes[0].InnerText == "fH&deg;gas")
                                        {
                                            NistFormationEnthlpyOrEntropy enthalpy = new NistFormationEnthlpyOrEntropy();
                                            enthalpy.quantity = rowNode.ChildNodes[0].InnerText;
                                            enthalpy.value = rowNode.ChildNodes[1].InnerText;
                                            enthalpy.units = rowNode.ChildNodes[2].InnerText;
                                            enthalpy.method = rowNode.ChildNodes[3].InnerText;
                                            enthalpy.reference = rowNode.ChildNodes[4].InnerText;
                                            enthalpy.comment = rowNode.ChildNodes[5].InnerText;
                                            enthalpies.Add(enthalpy);
                                        }
                                        if (rowNode.ChildNodes[0].InnerText == "S&deg;gas")
                                        {
                                            NistFormationEnthlpyOrEntropy entropy = new NistFormationEnthlpyOrEntropy();
                                            entropy.quantity = rowNode.ChildNodes[0].InnerText;
                                            entropy.value = rowNode.ChildNodes[1].InnerText;
                                            entropy.units = rowNode.ChildNodes[2].InnerText;
                                            entropy.method = rowNode.ChildNodes[3].InnerText;
                                            entropy.reference = rowNode.ChildNodes[4].InnerText;
                                            entropy.comment = rowNode.ChildNodes[5].InnerText;
                                            entropies.Add(entropy);
                                        }
                                    }
                                    if (rowNode.ChildNodes.Count == 4)
                                    {
                                        if (rowNode.ChildNodes[0].InnerText != "Cp,gas (J/mol*K)")
                                        {
                                            {
                                                NistCP cp = new NistCP();
                                                cp.value = rowNode.ChildNodes[0].InnerText;
                                                cp.temperature = rowNode.ChildNodes[1].InnerText;
                                                cp.reference = rowNode.ChildNodes[2].InnerText;
                                                cp.comment = rowNode.ChildNodes[3].InnerText;
                                                cps.Add(cp);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (NextTableShomate && tableNode.Name == "table")
                        {

                        }
                    }
                }
            }
        }
예제 #2
0
        void GetNISTLiquidData(string casNo, ref string enthalpy, ref string entropy, ref string cp)
        {
            List<NistFormationEnthlpyOrEntropy> enthalpies = new List<NistFormationEnthlpyOrEntropy>();
            List<NistFormationEnthlpyOrEntropy> entropies = new List<NistFormationEnthlpyOrEntropy>();
            List<NistCP> cps = new List<NistCP>();
            string url = "http://webbook.nist.gov/cgi/cbook.cgi?ID=C" + casNo.Replace("-", string.Empty) + "&Units=SI&Mask=2#Thermo-Condensed";
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
            System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.StringReader reader = new System.IO.StringReader(new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd());


            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.Load(reader);
            foreach (HtmlAgilityPack.HtmlNode bodyNode in document.DocumentNode.ChildNodes.Nodes())
            {
                if (bodyNode.Name == "body")
                {
                    foreach (HtmlAgilityPack.HtmlNode tableNode in bodyNode.ChildNodes)
                    {
                        if (tableNode.Name == "table")
                        {
                            foreach (HtmlAgilityPack.HtmlNode rowNode in tableNode.ChildNodes)
                            {
                                if (rowNode.Name == "tr")
                                {
                                    if (rowNode.ChildNodes.Count == 6)
                                    {
                                        if (rowNode.ChildNodes[0].InnerText == "fH&deg;liquid" || rowNode.ChildNodes[0].InnerText == "fH&deg;solid")
                                        {
                                            NistFormationEnthlpyOrEntropy newVal = new NistFormationEnthlpyOrEntropy();
                                            newVal.quantity = rowNode.ChildNodes[0].InnerText;
                                            newVal.value = rowNode.ChildNodes[1].InnerText;
                                            newVal.units = rowNode.ChildNodes[2].InnerText;
                                            newVal.method = rowNode.ChildNodes[3].InnerText;
                                            newVal.reference = rowNode.ChildNodes[4].InnerText;
                                            newVal.comment = rowNode.ChildNodes[5].InnerText;
                                            enthalpies.Add(newVal);
                                        }
                                        if (rowNode.ChildNodes[0].InnerText == "S&deg;liquid" || rowNode.ChildNodes[0].InnerText == "S&deg;solid")
                                        {
                                            NistFormationEnthlpyOrEntropy newVal = new NistFormationEnthlpyOrEntropy();
                                            newVal.quantity = rowNode.ChildNodes[0].InnerText;
                                            newVal.value = rowNode.ChildNodes[1].InnerText;
                                            newVal.units = rowNode.ChildNodes[2].InnerText;
                                            newVal.method = rowNode.ChildNodes[3].InnerText;
                                            newVal.reference = rowNode.ChildNodes[4].InnerText;
                                            newVal.comment = rowNode.ChildNodes[5].InnerText;
                                            entropies.Add(newVal);
                                        }
                                    }
                                    if (rowNode.ChildNodes.Count == 4)
                                    {
                                        if (rowNode.ChildNodes[0].InnerText != "Cp,liquid (J/mol*K)")
                                        {
                                            NistCP testVal = new NistCP();
                                            testVal.value = rowNode.ChildNodes[0].InnerText;
                                            testVal.temperature = rowNode.ChildNodes[1].InnerText;
                                            testVal.reference = rowNode.ChildNodes[2].InnerText;
                                            testVal.comment = rowNode.ChildNodes[3].InnerText;
                                            cps.Add(testVal);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }