Advertisement
Guest User

トレードアイランド年間成績

a guest
Jan 3rd, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 18.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using System.Net;
  7. using System.Xml;
  8. using System.Xml.Serialization;
  9.  
  10.  
  11.  
  12. namespace GetTradeIslandYearRanking
  13. {
  14.     class Program
  15.     {
  16.         static void Main(string[] args)
  17.         {
  18.             CookieContainer cc = new CookieContainer();
  19.             List<Dictionary<string, RankingInfo>> all_month_list = new List<Dictionary<string, RankingInfo>>();
  20.             HashSet<string> uid_hash = new HashSet<string>();
  21.  
  22.             // mm < 6とすれば過去6ヶ月間の成績になる
  23.             for (int mm = 0; mm < 12; mm++) {
  24.                 int year = 0, month = 0;
  25.  
  26.                 Dictionary<string, RankingInfo> this_month_dic = new Dictionary<string, RankingInfo>();
  27.                 all_month_list.Add(this_month_dic);
  28.  
  29.                 bool 収益順 = true;
  30.                 for (int page = 1; ; page++) {
  31.  
  32.                     string url;
  33.                     // アクセス数を減らすため損益が0がヒットしたら逆順に変更する
  34.                     // 収益額+順
  35.                     // https://www.click-sec.com/trade/rank.html?n=100&c=b
  36.                     // 収益額-順
  37.                     // https://www.click-sec.com/trade/rank.html?n=100&c=b&d=1
  38.  
  39.                     if (収益順) {
  40.                         url = "https://www.click-sec.com/trade/rank.html?c=b&n=100&mm=" + mm + "&pageID=" + page;
  41.                     } else {
  42.                         url = "https://www.click-sec.com/trade/rank.html?c=b&d=1&n=100&mm=" + mm + "&pageID=" + page;
  43.                     }
  44.                     string html;
  45.                     if (Util.GetPage(cc, url, Util.GetUTF8(), out html) == false) {
  46.                         Console.WriteLine("Error: GetPage failed");
  47.                         break;
  48.                     }
  49.                     if (page == 1 && 収益順) {
  50.                         string date_str = Util.Mid(html, ">", "<", "selected");
  51.                         if (Util.IsEmp(date_str)) {
  52.                             Console.WriteLine("Error: date_str == null");
  53.                             break;
  54.                         }
  55.                         DateTime d;
  56.                         if (DateTime.TryParse(date_str + "01日", out d) == false) {
  57.                             Console.WriteLine("Error: date_str(" + date_str + ") bad format");
  58.                             break;
  59.                         }
  60.                         year = d.Year;
  61.                         month = d.Month;
  62.                     }
  63.  
  64.                     bool last_page = false;
  65.                     if (html.IndexOf("next page") == -1) {
  66.                         last_page = true;
  67.                     }
  68.                     string table_str = Util.Mid(html, "<tbody>", "</table>");
  69.                     if (Util.IsEmp(table_str)) {
  70.                         Console.WriteLine("Error: table_str == null");
  71.                         break;
  72.                     }
  73.                     List<List<string>> table = Util.ParseTable(table_str);
  74.                     if (table == null || table.Count == 0) {
  75.                         Console.WriteLine("Error: table == null");
  76.                         break;
  77.                     }
  78.                     if (table.Count % 3 != 0) {
  79.                         Console.WriteLine("Error: table.Count % 3 != 0");
  80.                         break;
  81.                     }
  82.  
  83.                     bool no_trade_hit = false;
  84.                     for (int i = 0; i < table.Count; i += 3) {
  85.                         if (table[i].Count != 11 || table[i+1].Count != 8 ) {
  86.                             Console.WriteLine("Warning: bad table format");
  87.                             continue;
  88.                         }
  89.  
  90.                         RankingInfo rinfo = new RankingInfo();
  91.                         rinfo.year = year;
  92.                         rinfo.month = month;
  93.                         rinfo.ranking = (int)ParseLong(table[i][0]);
  94.  
  95.                         rinfo.uid = Util.Mid(table[i][2], "uid=", "\"");
  96.                         if (Util.IsEmp(rinfo.uid)) {
  97.                             continue;
  98.                         }
  99.                         uid_hash.Add(rinfo.uid);
  100.  
  101.                         rinfo.now_money = ParseLong(table[i][4]);
  102.                         rinfo.kabu_count = ParseLong(table[i][5]);
  103.                         rinfo.op_count = ParseLong(table[i][6]);
  104.                         rinfo.fx_count = ParseLong(table[i][7]);
  105.                         rinfo.fx_op_count = ParseLong(table[i][8]);
  106.                         rinfo.click_365_count = ParseLong(table[i][9]);
  107.                         rinfo.cfd_count = ParseLong(table[i][10]);
  108.  
  109.                         rinfo.profit = ParseLong(table[i + 1][0]);
  110.                         rinfo.start_money = ParseLong(table[i + 1][1]);
  111.                         rinfo.kabu_money = ParseLong(table[i + 1][2]);
  112.                         rinfo.op_money = ParseLong(table[i + 1][3]);
  113.                         rinfo.fx_money = ParseLong(table[i + 1][4]);
  114.                         rinfo.fx_op_money = ParseLong(table[i + 1][5]);
  115.                         rinfo.click_365_money = ParseLong(table[i + 1][6]);
  116.                         rinfo.cfd_money = ParseLong(table[i + 1][7]);
  117.  
  118.                         if (rinfo.profit == 0) {
  119.                             no_trade_hit = true;
  120.                             continue;
  121.                         }
  122.  
  123.                         if (this_month_dic.ContainsKey(rinfo.uid)) {
  124.                             Console.WriteLine("Warning: dup uid");
  125.                             continue;
  126.                         }
  127.  
  128.                         this_month_dic.Add(rinfo.uid, rinfo);
  129.                     }
  130.  
  131.                     if (no_trade_hit) {
  132.                         if (収益順) {
  133.                             収益順 = false;
  134.                             page = 0;
  135.                             continue;
  136.                         } else {
  137.                             break;
  138.                         }
  139.                     }
  140.                     if (last_page) {
  141.                         break;
  142.                     }
  143.                 }
  144.             }
  145.  
  146.             List<TraderInfo> tinfo_list = new List<TraderInfo>();
  147.             foreach (string uid in uid_hash) {
  148.                 TraderInfo tinfo = new TraderInfo();
  149.                 tinfo_list.Add(tinfo);
  150.  
  151.                 tinfo.uid = uid;
  152.  
  153.                 for (int i = 0; i < all_month_list.Count; i++) {
  154.                     RankingInfo rinfo;
  155.                     if (all_month_list[i].TryGetValue(uid, out rinfo) == false) {
  156.                         continue;
  157.                     }
  158.                     tinfo.profit += rinfo.profit;
  159.                     tinfo.cnt++;
  160.                     tinfo.rinfo_list.Add(rinfo);
  161.                     if (rinfo.profit > 0) {
  162.                         tinfo.win_cnt++;
  163.                     } else if (rinfo.profit < 0) {
  164.                         tinfo.lose_cnt++;
  165.                     }
  166.                 }
  167.             }
  168.             tinfo_list.Sort();
  169.  
  170.  
  171.  
  172.             Console.WriteLine("損益額ランキング");
  173.             for (int i = 0; i < 10; i++) {
  174.                 Console.WriteLine("" + (i + 1) + "位:\t" + tinfo_list[i].profit.ToString("n0") + "\t" + tinfo_list[i].uid);
  175.             }
  176.             Console.WriteLine();
  177.             Console.WriteLine("毎月勝ってる人");
  178.             int num = 1;
  179.             for (int i = 0; i < tinfo_list.Count; i++) {
  180.                 if (tinfo_list[i].cnt != 12 || tinfo_list[i].win_cnt != 12) {
  181.                     continue;
  182.                 }
  183.                 Console.WriteLine("" + num + "位:\t" + tinfo_list[i].profit.ToString("n0") + "\t" + tinfo_list[i].uid);
  184.                 num++;
  185.                 if (num > 10) {
  186.                     break;
  187.                 }
  188.             }
  189.             Console.WriteLine();
  190.  
  191.             long total_profit = 0;
  192.             long all_cnt = 0;
  193.             long win_cnt = 0, lose_cnt = 0, all_month_win = 0, all_month_lose = 0;
  194.             int money_10000_cnt = 0, money_5000_cnt = 0, money_3000_cnt = 0, money_1000_cnt = 0, money_500_cnt = 0, money_300_cnt = 0, money_100_cnt = 0, money_0_cnt = 0;
  195.             int minus_money_10000_cnt = 0, minus_money_5000_cnt = 0, minus_money_3000_cnt = 0, minus_money_1000_cnt = 0, minus_money_500_cnt = 0, minus_money_300_cnt = 0, minus_money_100_cnt = 0, minus_money_0_cnt = 0;
  196.  
  197.             List<TraderInfo> list_10000 = new List<TraderInfo>(), list_5000 = new List<TraderInfo>(), list_3000 = new List<TraderInfo>(), list_1000 = new List<TraderInfo>(),
  198.                     list_500 = new List<TraderInfo>(), list_300 = new List<TraderInfo>(), list_100 = new List<TraderInfo>(), list_0 = new List<TraderInfo>(),
  199.                     list_m_10000 = new List<TraderInfo>(), list_m_5000 = new List<TraderInfo>(), list_m_3000 = new List<TraderInfo>(), list_m_1000 = new List<TraderInfo>(),
  200.                     list_m_500 = new List<TraderInfo>(), list_m_300 = new List<TraderInfo>(), list_m_100 = new List<TraderInfo>(), list_m_0 = new List<TraderInfo>();
  201.  
  202.  
  203.  
  204.             for (int i = 0; i < tinfo_list.Count; i++) {
  205.  
  206.                 if (tinfo_list[i].cnt == 12 && tinfo_list[i].win_cnt == 12) {
  207.                     all_month_win++;
  208.                 }
  209.                 if (tinfo_list[i].cnt == 12 && tinfo_list[i].lose_cnt == 12) {
  210.                     all_month_lose++;
  211.                 }
  212.  
  213.                 total_profit += tinfo_list[i].profit;
  214.                 if (tinfo_list[i].profit > 0) {
  215.                     win_cnt++;
  216.                 } else if (tinfo_list[i].profit < 0) {
  217.                     lose_cnt++;
  218.                 }
  219.                 if (tinfo_list[i].profit != 0) {
  220.                     all_cnt++;
  221.                 }
  222.  
  223.                 if (tinfo_list[i].profit >= 10000L * 10000L) {
  224.                     money_10000_cnt++;
  225.                     list_10000.Add(tinfo_list[i]);
  226.                 } else if (tinfo_list[i].profit >= 5000L * 10000L) {
  227.                     money_5000_cnt++;
  228.                     list_5000.Add(tinfo_list[i]);
  229.                 } else if (tinfo_list[i].profit >= 3000L * 10000L) {
  230.                     money_3000_cnt++;
  231.                     list_3000.Add(tinfo_list[i]);
  232.                 } else if (tinfo_list[i].profit >= 1000L * 10000L) {
  233.                     money_1000_cnt++;
  234.                     list_1000.Add(tinfo_list[i]);
  235.                 } else if (tinfo_list[i].profit >= 500L * 10000L) {
  236.                     money_500_cnt++;
  237.                     list_500.Add(tinfo_list[i]);
  238.                 } else if (tinfo_list[i].profit >= 300L * 10000L) {
  239.                     money_300_cnt++;
  240.                     list_300.Add(tinfo_list[i]);
  241.                 } else if (tinfo_list[i].profit >= 100L * 10000L) {
  242.                     money_100_cnt++;
  243.                     list_100.Add(tinfo_list[i]);
  244.                 } else if (tinfo_list[i].profit > 0) {
  245.                     money_0_cnt++;
  246.                     list_0.Add(tinfo_list[i]);
  247.                 } else if (tinfo_list[i].profit <= -10000L * 10000L) {
  248.                     minus_money_10000_cnt++;
  249.                     list_m_10000.Add(tinfo_list[i]);
  250.                 } else if (tinfo_list[i].profit <= -5000L * 10000L) {
  251.                     minus_money_5000_cnt++;
  252.                     list_m_5000.Add(tinfo_list[i]);
  253.                 } else if (tinfo_list[i].profit <= -3000L * 10000L) {
  254.                     minus_money_3000_cnt++;
  255.                     list_m_3000.Add(tinfo_list[i]);
  256.                 } else if (tinfo_list[i].profit <= -1000L * 10000L) {
  257.                     minus_money_1000_cnt++;
  258.                     list_m_1000.Add(tinfo_list[i]);
  259.                 } else if (tinfo_list[i].profit <= -500L * 10000L) {
  260.                     minus_money_500_cnt++;
  261.                     list_m_500.Add(tinfo_list[i]);
  262.                 } else if (tinfo_list[i].profit <= -300L * 10000L) {
  263.                     minus_money_300_cnt++;
  264.                     list_m_300.Add(tinfo_list[i]);
  265.                 } else if (tinfo_list[i].profit <= -100L * 10000L) {
  266.                     minus_money_100_cnt++;
  267.                     list_m_100.Add(tinfo_list[i]);
  268.                 } else if (tinfo_list[i].profit < 0) {
  269.                     minus_money_0_cnt++;
  270.                     list_m_0.Add(tinfo_list[i]);
  271.                 }
  272.  
  273.             }
  274.  
  275.             Console.WriteLine("参加者損益合計: " + total_profit.ToString("n0"));
  276.             Console.WriteLine("年初から+の参加者数: " + win_cnt + GetParcentWithSpace(win_cnt, all_cnt));
  277.             Console.WriteLine("年初から-の参加者数: " + lose_cnt + GetParcentWithSpace(lose_cnt, all_cnt));
  278.             Console.WriteLine("今年全勝: " + all_month_win);
  279.             Console.WriteLine("今年全敗: " + all_month_lose);
  280.             Console.WriteLine("+10000万以上利益: " + money_10000_cnt + GetParcentWithSpace(money_10000_cnt, all_cnt) + GetAve(list_10000));
  281.             Console.WriteLine("+5000万以上利益: " + money_5000_cnt + GetParcentWithSpace(money_5000_cnt, all_cnt) + GetAve(list_5000));
  282.             Console.WriteLine("+3000万以上利益: " + money_3000_cnt + GetParcentWithSpace(money_3000_cnt, all_cnt) + GetAve(list_3000));
  283.             Console.WriteLine("+1000万以上利益: " + money_1000_cnt + GetParcentWithSpace(money_1000_cnt, all_cnt) + GetAve(list_1000));
  284.             Console.WriteLine("+500万以上利益: " + money_500_cnt + GetParcentWithSpace(money_500_cnt, all_cnt) + GetAve(list_500));
  285.             Console.WriteLine("+300万以上利益: " + money_300_cnt + GetParcentWithSpace(money_300_cnt, all_cnt) + GetAve(list_300));
  286.             Console.WriteLine("+100万以上利益: " + money_100_cnt + GetParcentWithSpace(money_100_cnt, all_cnt) + GetAve(list_100));
  287.             Console.WriteLine("+1円以上利益: " + money_0_cnt + GetParcentWithSpace(money_0_cnt, all_cnt) + GetAve(list_0));
  288.             Console.WriteLine("-1円以上損失: " + minus_money_0_cnt + GetParcentWithSpace(minus_money_0_cnt, all_cnt) + GetAve(list_m_0));
  289.             Console.WriteLine("-100万以上損失: " + minus_money_100_cnt + GetParcentWithSpace(minus_money_100_cnt, all_cnt) + GetAve(list_m_100));
  290.             Console.WriteLine("-300万以上損失: " + minus_money_300_cnt + GetParcentWithSpace(minus_money_300_cnt, all_cnt) + GetAve(list_m_300));
  291.             Console.WriteLine("-500万以上損失: " + minus_money_500_cnt + GetParcentWithSpace(minus_money_500_cnt, all_cnt) + GetAve(list_m_500));
  292.             Console.WriteLine("-1000万以上損失: " + minus_money_1000_cnt + GetParcentWithSpace(minus_money_1000_cnt, all_cnt) + GetAve(list_m_1000));
  293.             Console.WriteLine("-3000万以上損失: " + minus_money_3000_cnt + GetParcentWithSpace(minus_money_3000_cnt, all_cnt) + GetAve(list_m_3000));
  294.             Console.WriteLine("-5000万以上損失: " + minus_money_5000_cnt + GetParcentWithSpace(minus_money_5000_cnt, all_cnt) + GetAve(list_m_5000));
  295.             Console.WriteLine("-10000万以上損失: " + minus_money_10000_cnt + GetParcentWithSpace(minus_money_10000_cnt, all_cnt) + GetAve(list_m_10000));
  296.  
  297.  
  298.  
  299.         }
  300.         static string GetAve(List<TraderInfo> list)
  301.         {
  302.             return "";
  303.  
  304.             string res = "";
  305.             if (list.Count == 0) {
  306.                 return res;
  307.             }
  308.             long all_money = 0;
  309.             for (int i = 0; i < list.Count; i++) {
  310.                 all_money += list[i].profit;
  311.             }
  312.             double ave = all_money / (double)list.Count;
  313.             res = " 合計:" + all_money.ToString("n0") + ", 平均:" + ((long)ave).ToString("n0");
  314.             return res;
  315.         }
  316.         static string GetParcentWithSpace(long num, long all)
  317.         {
  318.             return "  (" + GetPercent(num, all) + ")";
  319.         }
  320.  
  321.         static string GetPercent(long num, long all)
  322.         {
  323.             double p = (num * 100) / (double)all;
  324.             return p.ToString("f2") + "%";
  325.         }
  326.         static long ParseLong(string str)
  327.         {
  328.             str = str.Replace(",", "");
  329.             str = str.Replace("円", "");
  330.             str = str.Replace("回", "");
  331.             str = str.Replace("千", "");
  332.             str = str.Replace("位", "");
  333.             str = str.Trim();
  334.             long l;
  335.             if (long.TryParse(str, out l) == false) {
  336.                 return -1;
  337.             }
  338.             return l;
  339.         }
  340.     }
  341.  
  342.     public class RankingInfo
  343.     {
  344.         public string uid;
  345.         public int year;
  346.         public int month;
  347.         public int ranking;
  348.         public long profit;         // 収益額
  349.         public long now_money;      // 現在資産
  350.         public long start_money;    // 当初資産
  351.         public long kabu_count;     // 株式回数
  352.         public long kabu_money;     // 株式約定代金
  353.  
  354.         public long op_count;
  355.         public long op_money;
  356.         public long fx_count;
  357.         public long fx_money;
  358.         public long fx_op_count;
  359.         public long fx_op_money;
  360.         public long click_365_count;
  361.         public long click_365_money;
  362.         public long cfd_count;
  363.         public long cfd_money;
  364.     }
  365.  
  366.     public class TraderInfo : IComparable
  367.     {
  368.         public string uid;
  369.         public long profit = 0;
  370.  
  371.         public int cnt = 0;
  372.         public int win_cnt = 0;
  373.         public int lose_cnt = 0;
  374.  
  375.         public List<RankingInfo> rinfo_list = new List<RankingInfo>();
  376.  
  377.         public int CompareTo(object obj)
  378.         {
  379.             if (obj is TraderInfo) {  // 型チェック
  380.                 TraderInfo temp = (TraderInfo)obj;
  381.                 return temp.profit.CompareTo(profit);
  382.             }
  383.             throw new ArgumentException("object is not a TraderInfo");
  384.         }
  385.     }
  386.     public class Util
  387.     {
  388.         public static bool IsEmp(string str)
  389.         {
  390.             if (str == null || str == "") {
  391.                 return true;
  392.             }
  393.             return false;
  394.         }
  395.  
  396.         public static bool GetPage(CookieContainer cc, string url, Encoding encoding, out string html)
  397.         {
  398.             html = "";
  399.             try {
  400.                 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  401.                 req.UserAgent = "MSIE 6.0";
  402.                 req.CookieContainer = cc;
  403.                 WebResponse res = req.GetResponse();
  404.                 Stream stm = res.GetResponseStream();
  405.                 if (stm != null) {
  406.                     StreamReader reader = new StreamReader(stm, encoding);
  407.                     string tmp = reader.ReadToEnd();
  408.                     html = tmp;
  409.                     reader.Close();
  410.                     stm.Close();
  411.                 }
  412.             } catch (WebException e) {
  413.                 return false;
  414.             } catch (Exception) {
  415.                 return false;
  416.             }
  417.             return true;
  418.         }
  419.  
  420.         static Encoding utf8 = Encoding.UTF8;
  421.         public static Encoding GetUTF8()
  422.         {
  423.             return utf8;
  424.         }
  425.         public static string Mid(string str, string start, string end)
  426.         {
  427.             return Mid(str, start, end, 0);
  428.         }
  429.         public static string Mid(string str, string start, string end, int offset)
  430.         {
  431.             if (str == null) {
  432.                 return null;
  433.             }
  434.             int s_index = 0;
  435.             if (start != null) {
  436.                 s_index = str.IndexOf(start, offset);
  437.             }
  438.             if (s_index == -1) {
  439.                 return null;
  440.             }
  441.             if (start != null) {
  442.                 s_index += start.Length;
  443.             }
  444.  
  445.             int e_index;
  446.             if (end == null) {
  447.                 e_index = str.Length;
  448.             } else {
  449.                 e_index = str.IndexOf(end, s_index);
  450.             }
  451.             if (e_index == -1) {
  452.                 return null;
  453.             }
  454.             return str.Substring(s_index, e_index - s_index);
  455.         }
  456.         public static string Mid(string str, string start, string end, string offset_keyword)
  457.         {
  458.             if (str == null) {
  459.                 return null;
  460.             }
  461.             int index = str.IndexOf(offset_keyword);
  462.             if (index == -1) {
  463.                 return null;
  464.             }
  465.             return Mid(str, start, end, index);
  466.         }
  467.  
  468.         public static List<string> Split(string str, string start, string end)
  469.         {
  470.             if (start == null || end == null) {
  471.                 return null;
  472.             }
  473.             List<string> arr = new List<string>();
  474.             int s_index, e_index, offset = 0;
  475.             while (true) {
  476.                 s_index = str.IndexOf(start, offset);
  477.                 if (s_index == -1) {
  478.                     break;
  479.                 }
  480.                 s_index += start.Length;
  481.                 e_index = str.IndexOf(end, s_index);
  482.                 if (e_index == -1) {
  483.                     break;
  484.                 }
  485.                 arr.Add(str.Substring(s_index, e_index - s_index));
  486.                 offset = e_index + end.Length;
  487.             }
  488.             return arr;
  489.         }
  490.  
  491.         public static List<string> SplitIgnoreCase(string str, string start, string end)
  492.         {
  493.             if (start == null || end == null) {
  494.                 return null;
  495.             }
  496.             List<string> arr = new List<string>();
  497.             int s_index, e_index, offset = 0;
  498.             while (true) {
  499.                 s_index = str.IndexOf(start, offset, StringComparison.OrdinalIgnoreCase);
  500.                 if (s_index == -1) {
  501.                     break;
  502.                 }
  503.                 s_index += start.Length;
  504.                 e_index = str.IndexOf(end, s_index, StringComparison.OrdinalIgnoreCase);
  505.                 if (e_index == -1) {
  506.                     break;
  507.                 }
  508.                 arr.Add(str.Substring(s_index, e_index - s_index));
  509.                 offset = e_index + end.Length;
  510.             }
  511.             return arr;
  512.         }
  513.  
  514.         public static string GetDateTimeStringEx(DateTime d, string deli)
  515.         {
  516.             return String.Format("{0:d4}" + deli + "{1:d2}" + deli + "{2:d2}", d.Year, d.Month, d.Day);
  517.         }
  518.         public static string RemoveTag(string html)
  519.         {
  520.             List<string> tags = Split(html, "<", ">");
  521.             if (tags == null) {
  522.                 return html;
  523.             }
  524.             for (int i = 0; i < tags.Count; i++) {
  525.                 string target = "<" + tags[i] + ">";
  526.                 html = html.Replace(target, "");
  527.             }
  528.             return html;
  529.         }
  530.         public enum ParseTableFlags : uint
  531.         {
  532.             Trim = (0x01 << 0),
  533.             RemoveTag = (0x01 << 1),
  534.             ALL = uint.MaxValue
  535.         }
  536.  
  537.         public static List<List<string>> ParseTable(string table, ParseTableFlags flags)
  538.         {
  539.             return ParseTable(table, (uint)flags);
  540.         }
  541.         public static List<List<string>> ParseTable(string table, uint flags)
  542.         {
  543.             bool neew_trim = (flags & (uint)ParseTableFlags.Trim) != 0;
  544.             bool neew_revtag = (flags & (uint)ParseTableFlags.RemoveTag) != 0;
  545.  
  546.             List<List<string>> list = new List<List<string>>();
  547.             List<string> trs = Util.SplitIgnoreCase(table, "<tr", "</tr>");
  548.             if (trs != null) {
  549.                 for (int i = 0; i < trs.Count; i++) {
  550.                     List<string> tds = Util.SplitIgnoreCase(trs[i], "<td", "</td>");
  551.                     if (tds != null) {
  552.                         for (int k = 0; k < tds.Count; k++) {
  553.                             tds[k] = Util.Mid(tds[k], ">", null);
  554.                             if (neew_revtag) {
  555.                                 tds[k] = Util.RemoveTag(tds[k]);
  556.                             }
  557.                             if (neew_trim) {
  558.                                 tds[k] = tds[k].Trim();
  559.                             }
  560.                         }
  561.                         list.Add(tds);
  562.                     }
  563.                 }
  564.             }
  565.             return list;
  566.         }
  567.         public static List<List<string>> ParseTable(string table)
  568.         {
  569.             return ParseTable(table, (uint)0);
  570.         }
  571.  
  572.  
  573.     }
  574.  
  575. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement