Example #1
0
 public static void Updata()
 {
     string URL = "http://apps.topcoder.com/wiki/display/tc/Algorithm+Problem+Set+Analysis?decorator=printable";
     string key = "Problem Set & Analysis";
     HTML.HTML html = new HTML.HTML(URL);
     List<Hashtable> info = html.GetDFSDocument();
     for (int i = 0; i < info.Count; i++)
         if ((string)info[i]["Value"] == key)
         {
             string tmp = (string)info[i - 1]["href"];
             tmp = tmp.Substring(1, tmp.Length - 2);
             if (tmp.StartsWith("http://apps.topcoder.com/wiki/display/tc/"))
                 UpdataNew(tmp);
             else
                 UpdataOld(tmp);
         }
 }
Example #2
0
 public void Updata()
 {
     String URL = "http://community.topcoder.com/stat?c=round_overview";
     HTML.HTML html = new HTML.HTML(URL);
     List<Hashtable> info = html.GetDFSDocument();
     foreach (Hashtable tmp in info)
         if ((string)tmp["Type"] == "TAG")
             if ((string)tmp["Value"] == "option")
                 if ((string)tmp["value"] != "\"#\"")
                 {
                     string src = (string)tmp["value"];
                     src = src.Substring(1, src.Length - 2);
                     int op;
                     for (op = src.Length - 1; op >= 0 && src[op] != '='; op--) ;
                     src = src.Substring(op + 1, src.Length - op - 1);
                     if (Directory.Exists(src) == false)
                         Directory.CreateDirectory("ProblemSet/" + src);
                 }
     UpdataComplete = true;
     Load();
 }
Example #3
0
 public static void UpdataNew(string URL)
 {
     Console.WriteLine("Start updata : " + URL);
     URL = URL + "?decorator=printable";
     string key = "Match Overview";
     HTML.HTML html = new HTML.HTML(URL);
     List<Hashtable> info = html.GetDFSDocument();
     string uid = "0";
     for (int i = 0; i < info.Count; i++)
         if ((string)info[i]["Value"] == key)
         {
             string tmp = (string)info[i - 1]["href"];
             tmp = tmp.Substring(1, tmp.Length - 2);
             uid = tmp.Split('=').Last();
             break;
         }
     if (uid == "0") return;
     string Path = "ProblemSet/" + uid;
     if (Directory.Exists(Path) == false) return;
     string DocPath = Path + "/Solution.doc";
     if (File.Exists(DocPath))
     {
         //string tmp = File.ReadAllText(Path);
         //if (tmp == "")
         File.Delete(DocPath);
         //else
         //    return;
     }
     if (Directory.Exists(Path + "/CSS") == false)
         Directory.CreateDirectory(Path + "/CSS");
     if (Directory.Exists(Path + "/Image") == false)
         Directory.CreateDirectory(Path + "/Image");
     string source = html.source;
     source = UpdataCSSandImage(Path, source);
     File.WriteAllText(DocPath, source);
     Console.WriteLine("Updata : " + URL + " Success!");
 }
Example #4
0
        public void Updata()
        {
            INIFILE INIinfo = new INIFILE(Path, "info.ini");
            String URL = GetRoundURL();
            HTML.HTML html = new HTML.HTML(URL);
            List<Hashtable> info = html.GetDFSDocument();

            //获取name
            for (int i = 0; i < info.Count; i++)
            {
                Hashtable tmp = info[i];
                if ((string)tmp["Type"] == "TAG")
                    if ((string)tmp["Value"] == "option")
                        if (checkURL((string)tmp["value"]) == true)
                        {
                            INIinfo.WriteString("contest", "name", (string)info[i + 1]["Value"]);
                            break;
                        }
            }

            //获取DIV信息
            DivList.Clear();
            int op = 0;
            bool find = true;
            while (find)
            {
                find = false;
                for (; op < info.Count && find == false; op++)
                {
                    Hashtable tmp = info[op];
                    if ((string)tmp["Type"] == "TAG")
                        if ((string)tmp["Value"] == "a")
                            if ((string)tmp["name"] == "\"problem_stats\"")
                            {
                                DivList.Add(new Div(ID, string.Format("Div{0}", DivList.Count + 1)));
                                int CountTR = 0;
                                for (; op < info.Count && CountTR < 2; op++)
                                {
                                    tmp = info[op];
                                    if ((string)tmp["Type"] == "TAG")
                                        if ((string)tmp["Value"] == "tr")
                                            CountTR++;
                                }
                                int CountTD = 0;
                                for (; op < info.Count && CountTD < 6; op++)
                                {
                                    tmp = info[op];
                                    if ((string)tmp["Type"] == "TAG")
                                        if ((string)tmp["Value"] == "td")
                                            CountTD++;
                                }
                                //获取题目信息
                                while (true)
                                {
                                    tmp = info[op];
                                    if ((string)tmp["Type"] == "TAG"
                                        && (string)tmp["Value"] == "tr")
                                    {
                                        CountTD = 0;
                                        for (int i = op + 1; i < info.Count; i++)
                                        {
                                            tmp = info[i];
                                            if ((string)tmp["Value"] == "td")
                                                CountTD++;
                                            else if ((string)tmp["Value"] == "tr")
                                                break;
                                        }
                                        if (CountTD != 7) break;
                                        Problem problem = new Problem(ID, DivList.Last().Name, (string)info[op +6]["Value"]);
                                        String problemids = (string)info[op + 5]["href"];
                                        problem.SetID(problemids.Split('=', '&')[3]);
                                        problem.Updata();
                                        op += 21;
                                    }
                                    else
                                        break;
                                }
                                find = true;
                                op--;
                            }
                }
            }

            UpdataComplete = true;
            Load();
        }
Example #5
0
        public void Updata()
        {
            LoadInfo();
            if (ID == "null") return;

            CookieCollection cookie = new CookieCollection();
            cookie.Add(new Cookie("main_user_id_1", "22768107|4d3c9fd95d28de4ac224108a2d79bd5d", "/", ".topcoder.com"));
            HTML.HTML html = new HTML.HTML(GetURL(),cookie);
            List<Hashtable> info = html.GetDFSDocument();

            for (int i = 0; i < info.Count; i++)
            {
                string tmp = (string)info[i]["Value"];
                if (tmp.Contains("Problem Statement for") == true)
                {
                    tmp = (string)info[i - 9]["Value"];
                    if (tmp == "table")
                    {
                        tmp = (string)info[i - 9]["Source"];
                        string findstr = "Problem Statement for ";
                        string replacestr = string.Format("<center><h1>{0}</h1></center>", Name);
                        for (int j = 0; j < tmp.Length && j+findstr.Length < tmp.Length; j++)
                            if (tmp.Substring(j, findstr.Length) == findstr)
                            {
                                for (int k = j+findstr.Length;k < tmp.Length;k++)
                                    if (tmp[k] == '<')
                                    {
                                        tmp = tmp.Substring(0, j) + replacestr + tmp.Substring(k);
                                        break;
                                    }
                                break;
                            }
                        File.WriteAllText(ProblemPath, tmp);
                        GetImage();
                    }
                    break;
                }
            }

            Load();
        }