使用Webbrower控件
private void btnStart_Click(object sender, EventArgs e) { try { CheckIsNull(txtUrl.Text.Trim(), "视频地址"); if (chkProxy.Checked) CheckIsNull(txtProxy.Text.Trim(), "代理服务器"); string urlPath = txtUrl.Text.Trim(); string proxyPath = txtProxy.Text.Trim(); string loneyUrl = string.Empty; List<string> urlList = null; List<string> proxyList = null; if (chkImport.Checked) urlList = GetListFromFile(urlPath); if (chkProxy.Checked) proxyList = GetListFromFile(proxyPath); //string url2 = "http://v.youku.com/v_show/id_XMTUzNDk1MDcwOA==.html?from=s1.8-1-1.2"; //string url1 = "http://v.youku.com/v_show/id_XMTUyNjI3Njg2OA==.html?from=s1.8-1-1.2"; this.cmbType.Enabled = false; this.btnStart.Enabled = false; this.btnStop.Enabled = true; this.labShow.Text = ""; this.labShow.Visible = true; stoped = false; int viewType = cmbType.SelectedIndex; if (!chkImport.Checked) { loneyUrl = txtUrl.Text.Trim(); } ThreadPool.QueueUserWorkItem(delegate(object obj) { //UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, useAge, useAge.Length, 0); while (!stoped) {Thread.Sleep(200);if (!chkImport.Checked){ ViewVido(loneyUrl, proxyList); Thread.Sleep((int)txtSleepTime.Value * 1000);}else{ switch (viewType) { case 0: IndexView(urlList, proxyList); break; default: RandomView(urlList, proxyList); Thread.Sleep((int)txtSleepTime.Value * 1000); break; }} } }); ThreadPool.QueueUserWorkItem(delegate(object obj) { while (!stoped) { Thread.Sleep(983); this.labShow.Invoke(new Action(() => { this.labShow.Text = string.Format("总计点击{0}个视频", count); })); } }); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
评论