你好,游客 登录
背景:
阅读新闻

被管理员和谐了的最高票答案“知乎数据抓取程序”(.net、c#数据挖掘)

[日期:2015-01-23] 来源:CSDN博客  作者:wuyidexinsheng [字体: ]

问:能利用爬虫技术做到哪些很酷很有趣很有用的事情?

准备学习python爬虫。各位大神都会用爬虫做哪些有趣的事情?

今天突然想玩玩爬虫,就提了这个问题。跟着YouTube上的一个tutor写了个简单的程序,爬了一点豆瓣的数据。主要用到request和bs4(BeautifulSoup)模块。虽然简陋,毕竟是人生中的第一只爬虫啊……以示纪念,代码写在博客里了:我的第一只爬虫:爬取豆瓣读书

 

没想到第一次答题居然登上了知乎互联网专栏的榜首了,也上了知乎首页,可惜被和谐了。

答:

监测她(他)的知乎,她关注、回答、赞了某个问题立马电脑和手机都弹出提示是不是很酷!先上两张图:


我 是个.NET程序猿,有一天女神告诉我有一个很不错的社区叫“知乎”,我经常一过来就看到她在看知乎,但每次我想看她都看了啥啊,她就遮住屏幕不让我看。 于是乎,在我心里埋下了一颗强烈的好奇心。知乎中搜了下她的名字,经过各种筛选知道了她的知乎空间。第一时间出现的想法是我要写个监测程序,她关注的所有 问题我都想知道。
连 续奋战5小时,至凌晨3点程序终于写出来了。主要HttpWebRequest加正则表达式来抓取数据,程序开机自动运行,数据库设在一台24小时开机的 服务器上。多个监测客户端同时运行,公司的,家里的,远程服务器上的。每隔5分钟自动循环读取一次数据,如果检测到关注了新的问题,立马将它们发送至我的 QQ邮箱和我的163邮箱,大家都知道QQ邮箱有提醒功能,一发过来,立马会弹出一个窗体告诉你有新的邮件。手机qq客户端也有,所以不管我是在上班的路 上,还是在电脑旁,只要她有新动态我立马就知道了。是不是很酷?
监 测程序已经运行三个多月了,收集了他二三百个关注的问题,我知道她一般都是吃中饭或者晚饭前喜欢看一下知乎,晚上睡前会看会,她睡得早但偶尔凌晨1点多还 看知乎。她关注情感类的问题最多,而且那段时间我一直在追她,所以我能根据她关注的问题来推测她的一些想法,包括约会聊天时我可以聊一些她感兴趣的话题。 所以实用性还是比较强的。
假如某一天凌晨1点,手机突然响了一下,发现她关注了某个问题。立马给她发一条短信过去,你是不是还没睡啊? 是啊,你怎么知道我没睡的? 凭感觉! 嘿嘿。 然后慢慢靠近她关注的那个话题去聊,这是不是会让她感觉到你特别懂她。好奇你居然知道她睡没睡,好奇你和她聊的话那么符合她的心声。

如此利器,有谁想要的吗? 赞超过一百,程序和源代码都放知乎上共享。

====21日9:37更新=====
没想到第一次答题就上榜了,好不开心,来来来,别停哈。怒上榜首,我开源12306抢票源码。我先赴约去开源我的知乎监测程序吧,一会把链接发过来。谢谢大家的赞!


===============


====21日11:50更新=====
《关于隐私》
先说明下,很多人都说我这样做侵犯隐私?没有吧,这些数据都是公开的啊,她也知道我关注了她呀,但蛋疼的知乎客户端没有这么细致的提醒功能,我甚至在客户端上找不到我都关注了哪些人。知乎手机app开发团队弱爆了,这么强有力的需求居然没有满足? 而且,知乎!你怎么就没有订阅功能呢?邮箱订阅! 我提出来啦哈,采纳了给我大V可好?

《关于匿不匿名》
FK, 男子汉大丈夫,匿啥名啊。女神知道了就知道了,又不是做什么伤天害理的事,敢作敢当!之所以写这么一个程序,也并不是完全的偷窥心理。对于一个程序员来 说,写出一个新鲜的程序是能给程序员一种很大的乐趣的,这一般人难以理解,想当年在学校时,通宵写俄罗斯方块,白天上课不听课在那研究一个方块当按左键是 什么样子什么逻辑,右键又怎样。这是非常有意思的事,编程其实是一个艺术活,好的框架和优质的代码让人一看就感觉特别享受。 所以我写这么个程序同样也是满足自己的一种乐趣。不必匿!

《关于女神追到没?》
追 到啦,哈哈!好爽啊,9月份去骑了趟川藏线,路遇佛像及经轮,我就祈祷我要娶她做老婆。且出发前找牛逼大神算了一卦(中国易学协会副会长),说我10月份 很有姻缘缘分。于是,我在世界三大冰川之一的-来古冰川的河床上找了一下午的石头,终于找到一颗天然红色心形的爱情石,回来后我就拿着石头跟她表白了,然 后就成了!虽然她说我表白像检讨一样,但也很感人!
可惜,我们在一起没多久就分手了。原因一两句话说不完,总之不管以后怎样。都祝福她,虽然在一起不长时间,但那是很美的回忆。我会珍藏!
===================


=====2015-1-21 上午11:16分更新=======

程序开源地址:

下载源程序http://download.csdn.net/detail/wuyidexinsheng/8382253
程序博文地址:http://blog.csdn.net/wuyidexinsheng/article/details/42964707


步入正题,思路描述:

下来源程序后,先自己去建数据库改配置哈,否则程序运行不起来的。
[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <span style="font-size:10px;"><?xml version="1.0"?> 
  2. <configuration> 
  3.   <appSettings> 
  4.     <!--数据有两种存储方式,一种存储于本地程序目录下的Ids.txt,但那只存了问题ID,完整的数据存于oracle数据库中--> 
  5.     <add key="connStr" value="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DZZH)));User Id=xxxxx;Password=xxxx"/> 
  6.     <!-- 设置监测循环时间:秒 --> 
  7.     <add key="Interval" value="600"/> 
  8.     <!--设置自动发送信息机器人邮箱--> 
  9.     <add key="smtpAddress" value="smtp.163.com"/> 
  10.     <!--用户名--> 
  11.     <add key="sendEmailFrom" value="xxxxxxxx@163.com"/> 
  12.     <!--密码--> 
  13.     <add key="sendEmailFromPwd" value="xxxxxxxxx"/> 
  14.     <!--接收邮箱地址--> 
  15.     <add key="strMailAddressTo" value="xxxxxxxx@163.com,xxxxxxxx@qq.com"/> 
  16.     <!--邮件名称抬头--> 
  17.     <add key="EmailName" value="zhApp-家里电脑"/> 
  18.     <!--END--> 
  19.     <!--监测地址--> 
  20.     <add key="WatchingURL" value="http://www.zhihu.com/people/wu-xin-sheng-7"/> 
  21.   </appSettings> 
  22.   <startup> 
  23.     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
  24.   </startup> 
  25. </configuration></span> 

第一步:通过Cinser.Common.HttpHelper.GetString(“www.zhihu.com/people/wu-xin-sheng-7”)读取给定的一个网址的后台代码:

结果如下图所示:


如我空间的源码中就有这么一段:

 

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <span class="name">伍新生</span><span class="bio" title="五颜六色的情感,我毕生的追求!">五颜六色的情感,我毕生的追求!</span> 
  2. </div> 
  3. </div> 
  4. <div class="body clearfix"> 
  5. <div class="zm-profile-header-avatar-container self"> 
  6. <img alt="伍新生" 
  7. src="http://pic4.zhimg.com/94cc60166_l.jpg" 
  8. class="zm-profile-header-img zg-avatar-big zm-avatar-editor-preview"/> 
  9.  
  10. <span class="zm-entry-head-avatar-edit-button">修改头像</span> 


第二步:通过调用方法private List<Question> GetQuestions(string source)截取关键数据。

原理很简单,所有知乎的问题都是如下的格式:<aclass="question_link"target="_blank"href="/question/27621722/answer/37636385">能利用爬虫技术做到哪些很酷很有趣很有用的事情?</a>

接下来那就是字符串截取呗:调用Cinser.Common.StringPlus.SubString(source, “<a class=\"question_link\”, "</a>")等依次截取问题的ID,名称等数据。

 

[csharp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. private List<Question> GetQuestions(string source) 
  2.             { 
  3.                 List<Question> questions = new List<Question>(); 
  4.                 string startStr = "<a class=\"question_link\""
  5.                 if (source.IndexOf(startStr) != -1) 
  6.                 { 
  7.                     Question q = new Question(); 
  8.                     string content = Cinser.Common.StringPlus.SubString(source, startStr, "</a>"); 
  9.                     q.Id = Cinser.Common.StringPlus.SubString(content, "question/""\""); 
  10.                     q.Title = content.Substring(content.IndexOf(">") + 1); 
  11.                     q.Time = DateTime.Now; 
  12.                     questions.Add(q); 
  13.                     source = source.Substring(source.IndexOf(startStr) + startStr.Length); 
  14.                     questions.AddRange(GetQuestions(source)); 
  15.                 } 
  16.                 return questions; 
  17.             } 


第三步:将取到的问题写入数据库,并写入本地Ids.txt。

因为5分钟读取一次数据,肯定会读取到部分已经度过的数据咯。就是通过取到id然后看Ids.txt里面这个id是不是已经存在了,如果存在了就表示已经抓去过啦。 

为什么问题都已经写到oracle数据库了还要往本地Ids.txt写一次呢,因为oracle数据库是部署在远程服务器上的啊。如果这台服务器突然出故障死机了,怎么办?程序还得要运行啊,所以程序往两个地方都写一次数据。如果oracle数据库不能访问,则通过读取和写入本地ids来记录问题。


数据抓取其实就这么简单。


如下是部分源码,也可以直接去下载源程序:http://download.csdn.net/detail/wuyidexinsheng/8382253

如下是程序主窗体源码:

 

[csharp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. public partial class Form1 : Form 
  2.     { 
  3.         DataProvider dal; 
  4.         string watchingURL = string.Empty; 
  5.         int LoopCount = 0; 
  6.         public Form1() 
  7.         { 
  8.             InitializeComponent(); 
  9.             dal = new DataProvider(); 
  10.             dal.AddLog("程序启动"); 
  11.  
  12.             base.WindowState = FormWindowState.Minimized; 
  13.             base.Show(); 
  14.             base.Hide(); 
  15.             base.WindowState = FormWindowState.Normal; 
  16.             base.ShowInTaskbar = false
  17.             base.TopMost = false
  18.             base.MaximizeBox = false
  19.             base.MinimizeBox = false
  20.             base.ControlBox = false
  21.  
  22.             //设置循环监测时间 
  23.             int interval = int.Parse(Cinser.Common.ConfigurationHelper.GetAppSettingsValue("Interval")); 
  24.             timer1.Interval = interval * 1000; 
  25.  
  26.             watchingURL = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("WatchingURL"); 
  27.             RunWhenStart(true"zhApp.exe""\"" + Application.StartupPath + "\\zhApp.exe\" AutoRun"); 
  28.             Run(); 
  29.             dal.AddLog("程序初始化成功"); 
  30.             LoopCount += 1; 
  31.         } 
  32.  
  33.         //设置程序开机自启动 
  34.         public void RunWhenStart(bool Started, string name, string path) 
  35.         { 
  36.             RegistryKey HKLM = Registry.CurrentUser; 
  37.             RegistryKey Run = HKLM.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); 
  38.             if (Started == true
  39.             { 
  40.                 try 
  41.                 { 
  42.                     Run.SetValue(name, path); 
  43.                     HKLM.Close(); 
  44.                 } 
  45.                 catch(Exception ex)//没有权限会异常   
  46.                 { 
  47.                     throw ex; 
  48.                 } 
  49.             } 
  50.             else 
  51.             { 
  52.                 try 
  53.                 { 
  54.                     Run.DeleteValue(name); 
  55.                     HKLM.Close(); 
  56.                 } 
  57.                 catch (Exception ex)//没有权限会异常   
  58.                 { 
  59.                     throw ex; 
  60.                 } 
  61.             } 
  62.         } 
  63.  
  64.         /// <summary> 
  65.         /// 运行监测流程 
  66.         /// </summary> 
  67.         private void Run() 
  68.         { 
  69.             List<Question> questions = GetQuestions(Cinser.Common.HttpHelper.GetString(watchingURL)); 
  70.             string ids = dal.GetExistIdsStr(); 
  71.             for (int i = 0; i < questions.Count; i++) 
  72.             { 
  73.                 if (ids.IndexOf(questions[i].Id) != -1) 
  74.                 { 
  75.                     questions.Remove(questions[i]); 
  76.                     i--; 
  77.                 } 
  78.                 else 
  79.                 { 
  80.                     if (ids == string.Empty) 
  81.                         ids = questions[i].Id; 
  82.                     else 
  83.                         ids += "," + questions[i].Id; 
  84.                 } 
  85.             } 
  86.             if (questions.Count > 0) 
  87.             { 
  88.                 SendQuestions(questions); 
  89.                 dal.WriteIdStrToTxt(ids); 
  90.                 dal.Add(questions); 
  91.                 dal.AddLog(string.Format("获取了{0}条新数据。", questions.Count));             
  92.             } 
  93.         } 
  94.  
  95.         /// <summary> 
  96.         /// 从监测站点源数据中抓取问题 
  97.         /// </summary> 
  98.         private List<Question> GetQuestions(string source) 
  99.         { 
  100.             List<Question> questions = new List<Question>(); 
  101.             string startStr = "<a class=\"question_link\""
  102.             if (source.IndexOf(startStr) != -1) 
  103.             { 
  104.                 Question q = new Question(); 
  105.                 string content = Cinser.Common.StringPlus.SubString(source, startStr, "</a>"); 
  106.                 q.Id = Cinser.Common.StringPlus.SubString(content, "question/""\""); 
  107.                 q.Title = content.Substring(content.IndexOf(">") + 1); 
  108.                 q.Time = DateTime.Now; 
  109.                 questions.Add(q); 
  110.                 source = source.Substring(source.IndexOf(startStr) + startStr.Length); 
  111.                 questions.AddRange(GetQuestions(source)); 
  112.             } 
  113.             return questions; 
  114.         } 
  115.  
  116.         private bool SendQuestions(List<Question> questions) 
  117.         { 
  118.             bool bSuccess = true
  119.             List<string> strMailAddressTo = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("strMailAddressTo").Split(',').ToList(); 
  120.             string smtpAddress = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("smtpAddress"); 
  121.             string sendEmailFrom = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("sendEmailFrom"); 
  122.             string sendEmailFromPwd = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("sendEmailFromPwd"); 
  123.             string emailName = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("EmailName"); 
  124.             //密码解密,开源的话就去掉这步吧,这样配置的时候直接配置明文密码就行。 
  125.             //sendEmailFromPwd = Cinser.Common.Security.DecryptDES(sendEmailFromPwd, "yuiophgf"); 
  126.             string msg = string.Empty; 
  127.             SendCompletedEventHandler s = new SendCompletedEventHandler(SendCompleted); 
  128.             string content = GetQustionsListStr(questions); 
  129.             content += "\n\n信息来源于:" + watchingURL; 
  130.             Cinser.Common.SmtpEmailSend.SendEmail(strMailAddressTo, emailName + DateTime.Now.ToString(), content, smtpAddress, 0x19, sendEmailFrom, sendEmailFromPwd, "163测试邮箱"nullout msg, s); 
  131.             return bSuccess; 
  132.         } 
  133.  
  134.         private void SendCompleted(object sender, AsyncCompletedEventArgs e) 
  135.         { 
  136.         } 
  137.          
  138.         private string GetQustionsListStr(List<Question> questions) 
  139.         { 
  140.             string content = string.Empty; 
  141.             if (questions != null && questions.Count > 0) 
  142.             { 
  143.                 content = string.Format("名称:{0},url:{1}", questions[0].Title, questions[0].Url); 
  144.                 for (int i = 1; i < questions.Count; i++) 
  145.                 { 
  146.                     content += string.Format("\n 名称:{0},url:{1}", questions[i].Title, questions[i].Url); 
  147.                 } 
  148.             } 
  149.             return content; 
  150.         } 
  151.  
  152.         private void timer1_Tick(object sender, EventArgs e) 
  153.         { 
  154.             int interval = int.Parse(Cinser.Common.ConfigurationHelper.GetAppSettingsValue("Interval")); 
  155.             timer1.Interval = interval * 1000; 
  156.             Run(); 
  157.             dal.AddLog(string.Format("程序循环次数:{0}", LoopCount++)); 
  158.         } 
  159.     } 


知乎问题model:Question.cs

[csharp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. public class Question 
  2.     string id, title, url, type, remark; 
  3.     DateTime time; 
  4.  
  5.     public string Remark 
  6.     { 
  7.         get { return remark; } 
  8.         set { remark = value; } 
  9.     } 
  10.  
  11.     public DateTime Time 
  12.     { 
  13.         get { return time; } 
  14.         set { time = value; } 
  15.     } 
  16.  
  17.     public string Type 
  18.     { 
  19.         get { return type; } 
  20.         set { type = value; } 
  21.     } 
  22.  
  23.     public string Url 
  24.     { 
  25.         get 
  26.         { 
  27.             if (string.IsNullOrEmpty(url)) 
  28.             { 
  29.                 url = string.Format("http://www.zhihu.com/question/{0}", Id); 
  30.             } 
  31.             return url; 
  32.         } 
  33.         set { url = value; } 
  34.     } 
  35.  
  36.     public string Title 
  37.     { 
  38.         get { return title; } 
  39.         set { title = value; } 
  40.     } 
  41.  
  42.     public string Id 
  43.     { 
  44.         get { return id; } 
  45.         set { id = value; } 
  46.     } 


数据操作类DataProvider.cs

[csharp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. /// <summary> 
  2.     ///  知乎问题数据表操作Provider 
  3.     /// </summary> 
  4.     public class DataProvider 
  5.     { 
  6.         private string connStr = string.Empty; 
  7.         Cinser.DBUtility.DAL.OracleDALCommon dal; 
  8.         string txtPath = ""
  9.         string logPath = ""
  10.         string debugPath = string.Empty; 
  11.  
  12.         public string DebugPath 
  13.         { 
  14.             get 
  15.             { 
  16.                 if (debugPath == string.Empty) 
  17.                     debugPath = System.AppDomain.CurrentDomain.BaseDirectory; 
  18.  
  19.                 if (debugPath.EndsWith("\\") == false
  20.                 { 
  21.                     debugPath += "\\"
  22.                 } 
  23.                 return debugPath; 
  24.             } 
  25.             set { debugPath = value; } 
  26.         } 
  27.  
  28.         public string LogPath 
  29.         { 
  30.             get 
  31.             { 
  32.                 if (logPath == string.Empty) 
  33.                 { 
  34.                     logPath = DebugPath + "Log.txt"
  35.                 } 
  36.                 return logPath; 
  37.             } 
  38.         } 
  39.  
  40.         public DataProvider() 
  41.         { 
  42.             dal = new Cinser.DBUtility.DAL.OracleDALCommon(this.ConnStr); 
  43.         } 
  44.  
  45.         public string TxtPath 
  46.         { 
  47.             get 
  48.             { 
  49.                 if (txtPath == string.Empty) 
  50.                 { 
  51.                     txtPath = DebugPath + "Ids.txt"
  52.                 } 
  53.                 return txtPath; 
  54.             } 
  55.         } 
  56.  
  57.         public string ConnStr 
  58.         { 
  59.             get 
  60.             { 
  61.                 if (connStr == string.Empty) 
  62.                 { 
  63.                     connStr = Cinser.Common.ConfigurationHelper.GetAppSettingsValue("connStr"); 
  64.                 } 
  65.                 return connStr; 
  66.             } 
  67.             set { connStr = value; } 
  68.         } 
  69.  
  70.         public bool CanConnectOracleServer 
  71.         { 
  72.             get 
  73.             { 
  74.                 return dal.Open(); 
  75.             } 
  76.         } 
  77.  
  78.         /// <summary> 
  79.         /// 将抓取到的问题写入oracle数据库中 
  80.         /// </summary> 
  81.         /// <param name="questions"></param> 
  82.         /// <returns></returns> 
  83.         public bool Add(List<Question> questions) 
  84.         { 
  85.             bool bReturn = false
  86.             try 
  87.             { 
  88.                 for (int i = 0; i < questions.Count; i++) 
  89.                 { 
  90.                     dal.Add("qustions", questions[i]); 
  91.                 } 
  92.                 bReturn = true
  93.             } 
  94.             catch { } 
  95.             return bReturn; 
  96.         } 
  97.  
  98.         public DataTable GetQustions(string sqlWhere = "1=1"
  99.         { 
  100.             try 
  101.             { 
  102.                 DataTable dt = dal.GetDataList("qustions", sqlWhere); 
  103.                 return dt; 
  104.             } 
  105.             catch 
  106.             { 
  107.                 return null
  108.             } 
  109.         } 
  110.  
  111.         public bool IsExist(string id) 
  112.         { 
  113.             try 
  114.             { 
  115.                 string sqlWhere = "id='" + id + "'"
  116.                 DataTable dt = dal.GetDataList("qustions", sqlWhere); 
  117.                 return dt.Rows.Count > 0; 
  118.             } 
  119.             catch 
  120.             { 
  121.                 return false
  122.             } 
  123.         } 
  124.  
  125.         /// <summary> 
  126.         /// 获取已经抓取过的问题ID字符串 
  127.         /// </summary> 
  128.         /// <returns></returns> 
  129.         public string GetExistIdsStr() 
  130.         { 
  131.             string ids = string.Empty; 
  132.             //如果能连上远程的oracle服务器则从oracle数据库中取ID字符串 
  133.             if (CanConnectOracleServer) 
  134.             { 
  135.                 DataTable dt = GetQustions(); 
  136.                 if (dt != null && dt.Rows.Count > 0) 
  137.                 { 
  138.                     ids = dt.Rows[0]["id"].ToString(); 
  139.                     for (int i = 1; i < dt.Rows.Count; i++) 
  140.                     { 
  141.                         ids += "," + dt.Rows[i]["id"].ToString();                         
  142.                     } 
  143.                 } 
  144.             } 
  145.             else 
  146.             {//如果能连上远程的oracle服务器关机了,连不上则从本地Ids.txt中取ID字符串            
  147.                 if (File.Exists(TxtPath)) 
  148.                     ids = File.ReadAllText(TxtPath); 
  149.             } 
  150.             return ids; 
  151.         } 
  152.  
  153.         /// <summary> 
  154.         /// 将最新取到的问题记录至ids.txt中,以此标记这些问题为已读问题 
  155.         /// </summary> 
  156.         /// <param name="ids"></param> 
  157.         public void WriteIdStrToTxt(string ids) 
  158.         { 
  159.             if (File.Exists(this.TxtPath) == false
  160.                 File.Create(TxtPath); 
  161.             File.WriteAllText(this.TxtPath, ids); 
  162.         } 
  163.  
  164.         /// <summary> 
  165.         /// 写程序log,方便错误追踪。 
  166.         /// </summary> 
  167.         /// <param name="LogMsg"></param> 
  168.         public void AddLog(string LogMsg) 
  169.         { 
  170.             string logStr = string.Format("{0}:{1}.\n", DateTime.Now.ToString(), LogMsg); 
  171.             if (File.Exists(this.LogPath) == false
  172.                 File.Create(LogPath); 
  173.             string[] logs = File.ReadAllLines(LogPath); 
  174.             if (logs.Length >= 520) 
  175.                 File.WriteAllText(LogPath, logStr); 
  176.             else 
  177.             { 
  178.                 StreamWriter sw = File.AppendText(LogPath); 
  179.                 sw.WriteLine(logStr); 
  180.                 sw.Close(); 
  181.             } 
  182.         } 
  183.     } 
  184. 原文链接:http://blog.csdn.net/wuyidexinsheng/article/details/42964707




收藏 推荐 打印 | 录入: | 阅读:
本文评论   查看全部评论 (4)
表情: 表情 姓名: 字数
点评:
       
评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款