数据采集(天天,百度百家)

Posted Q & L

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据采集(天天,百度百家)相关的知识,希望对你有一定的参考价值。

爆文采集系统后台数据支撑:百度百家以及天天快报等等。。

 

简单采集过程,不再复述。

重点放在新学的线程以及桌面应用程序:

1、线程部分,   开始、暂停、继续、结束

 1      public enum opState
 2         {
 3             none,   //无操作
 4             pause,  //暂停
 5             go_on,  //继续
 6             stop    //停止
 7         }
 8         private Thread myThread = null;
 9         private bool myThreadRun = false;
10         private opState state = opState.none;
11         private delegate void ShowMsgHandler(string msg);
12         public Form1()
13         {
14             InitializeComponent();
15         }
16 
17         /// <summary>
18         /// 开始
19         /// </summary>
20         private void button1_Click(object sender, EventArgs e)
21         {
22             if (myThread == null || myThread.ThreadState == ThreadState.Stopped)
23             {
24                 myThreadRun = true;
25                 myThread = new Thread(new ThreadStart(runPro));
26                 myThread.IsBackground = true;
27                 myThread.Start();
28             }
29             else
30             {
31                 myThreadRun = false;
32             }
33         }
34 
35         public void runPro()
36         {
37             for (int i = 0; i < 10000; i++)
38             {
39                 //状态开关控制
40                 switch (state)
41                 {
42                     case opState.pause:
43                         i--;
44                         continue;
45                     case opState.go_on:
46                         break;
47                     case opState.none:
48                         break;
49                     case opState.stop:
50                         return;
51                 }
52                 if (this.InvokeRequired)
53                 {
54                     this.Invoke(new ShowMsgHandler(ShowMsg), i.ToString());
55                 }
56                 else
57                 {
58                     ShowMsg(i.ToString());
59                 }
60                 //Thread.Sleep(100);
61             }
62         }
63         private void ShowMsg(string msg)
64         {
65             this.textBox1.AppendText(msg + "\r\n");
66         }
67 
68         /// <summary>
69         /// 暂停
70         /// </summary>
71         private void button2_Click(object sender, EventArgs e)
72         {
73             state = opState.pause;
74         }
75 
76         /// <summary>
77         /// 继续
78         /// </summary>
79         private void button3_Click(object sender, EventArgs e)
80         {
81             state = opState.go_on;
82         }
83 
84         /// <summary>
85         /// 停止
86         /// </summary>
87         private void button4_Click(object sender, EventArgs e)
88         {
89             state = opState.stop;
90             myThreadRun = false;
91         }

2、窗体应用程序

2.1、异步加载输出

1 this.Invoke(new Action(() =>
2 {
3   label2.Text = subject_name;
   textBox.AppendText("" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "】 ----添加新作者:" + writer_name + "\r\n" + "\r\n"); 5 textBox.ScrollToCaret();//下拉框 6 }));

2.2、时间插件

ps:记得修改插件属性Interval的值为1000

 1 private void timer1_Tick(object sender, EventArgs e)
 2         {
 3             Second_++;
 4             if (Second_ == 60)
 5             {
 6                 Second_ = 0;
 7                 Minute_++;
 8             }
 9             if (Minute_ == 60)
10             {
11                 Minute_ = 0;
12                 Hour_++;
13             }
14             label7.Text = Hour_ + "" + Minute_ + "" + Second_;
15         }

-----------kylin

以上是关于数据采集(天天,百度百家)的主要内容,如果未能解决你的问题,请参考以下文章

测试百度百家的另类SEO优化方法

百度搜索结果屏蔽百家号方法

为什么在网络平台玩百家乐最后还是输

百度低调入局百家号直播带货再续电商梦

百度百家号“漏洞”大曝光 一篇文章十几万阅读量 收入上万

依然不放弃电商的百度以百家号直播带货再次入局短视频行业