Esempio n. 1
0
        static void getD2PassSites()
        {
            AVSyncerDataContext dc  = new AVSyncerDataContext();
            HtmlDocument        doc = new HtmlDocument();

            doc.Load(@"..\..\sites.html", Encoding.UTF8);
            var sitesNodes = doc.DocumentNode.CssSelect(".list-siteinfo");

            foreach (var siteinfo in sitesNodes)
            {
                try {
                    var maker = new Maker();
                    maker.name        = siteinfo.CssSelect(".sitename-label").First().InnerText.Trim();
                    maker.description = siteinfo.CssSelect(".comment").First().InnerText.Trim();
                    maker.url         = siteinfo.CssSelect(".sitename-label").First().GetNextSibling("td").CssSelect("a").First().Attributes["href"].Value;
                    dc.Maker.InsertOnSubmit(maker);
                    dc.SubmitChanges();
                } catch (Exception e) {
                    System.Diagnostics.Debug.Write(e.Message + "\n" + e.StackTrace + "\n");
                    continue;
                }
            }

            System.Diagnostics.Debug.Write("\n");
        }
Esempio n. 2
0
        static void desJSON(string json)
        {
            try {
                AVSyncerDataContext      dc        = new AVSyncerDataContext();
                Dictionary <string, int> MakerList = new Dictionary <string, int>();

                var tt = json.Substring(6, json.Length - 9);
                JavaScriptSerializer ser = new JavaScriptSerializer();
                Item xx = ser.Deserialize <Item>(tt);
                foreach (var review in xx.reviews)
                {
                    if (!MakerList.ContainsKey(review.site_name))
                    {
                        MakerList.Add(review.site_name, 0);
                    }
                }
                //foreach (var key in MakerList.Keys) {
                //    Maker maker = new Maker();
                //    maker.name = key;
                //    maker.description = key;
                //    dc.Maker.InsertOnSubmit(maker);
                //    dc.SubmitChanges();
                //}
                System.Diagnostics.Debug.Write("");
            } catch (Exception e) {
                System.Diagnostics.Debug.Write(e.StackTrace);
            }
        }