Dictionary<string, string> users = new Dictionary<string, string>();
users.Add("userName1", "password");
users.Add("userName2", "password");
users.Add("userName3", "password");
DataTable dt = new DataTable() ;
dt.Columns.Add("UserName");
dt.Columns.Add("apiKey");
dt.Columns.Add("robtName");
dt.Columns.Add("chatCount");
foreach (var item2 in users)
{
    var httpHelper = new HttpHelper();
    var login = httpHelper.GetHtml(new HttpItem() { URL = string.Format("http://sso.tuling123.com/sso-api/login/p/1?username={0}&password={1}", item2.Key, item2.Value) });
    var homePage = httpHelper.GetHtml(new HttpItem() { URL = "http://www.tuling123.com/member/robot/index.jhtml", Cookie = login.Cookie });
    Dictionary<string, int> result = new Dictionary<string, int>();
    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
    doc.LoadHtml(homePage.Html);
    var robots = doc.DocumentNode.SelectNodes("//ul[@class='robots']/li");
    for (int i = 0; i < robots.Count - 1; i++)
    {
        var item = robots[i];
        var dr = dt.NewRow();
        dr["UserName"] = item2.Key;
        dr["apiKey"] = item.Attributes["apikey"].Value;
        dr["robtName"] = item.SelectSingleNode("div[@class='robot-name']").InnerText;
        dr["chatCount"] = item.SelectSingleNode("div[@class='before-chat']").InnerText.Replace("今日聊天数量:", "").Trim();
        dt.Rows.Add(dr);
    }
    dt.Rows.Add(dt.NewRow());
}

 

相关文章:

  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2021-09-27
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2021-10-24
  • 2021-11-28
  • 2021-11-11
  • 2021-12-25
  • 2021-12-14
相关资源
相似解决方案