zoukankan      html  css  js  c++  java
  • C#采集:图灵机器人信息

    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());
    }
  • 相关阅读:
    Django入门
    RCNN 研究相关
    [Android UI]View滑动方式总结
    [Android UI]View基础知识
    [Android]Android开发艺术探索第1章笔记
    [Leetcode]017. Letter Combinations of a Phone Number
    java之this关键字
    POJ 1000 A+B
    [Leetcode]016. 3Sum Closest
    [Leetcode]015. 3Sum
  • 原文地址:https://www.cnblogs.com/linmilove/p/8992427.html
Copyright © 2011-2022 走看看