1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Windows.Forms;
5
6 namespace SuperDLL
7 {
8 public static class WebBrowser
9 {
10 public static void Crawler()
11 {
12 System.Timers.Timer time = new System.Timers.Timer(2000);
13 time.Elapsed += (obj, es) =>
14 {
15 try
16 {
17 WebBrowser WinWebBrowser = new WebBrowser();
18 HtmlDocument doc = WinWebBrowser.Document;
19 HtmlElement key = doc.GetElementById("id");
20 key.Focus();
21 key.InnerText = "Content";
22 SendKeys.Flush();
23 key = doc.GetElementById("loginBtn").Children[1].Children[0];
24 key.Focus();
25 key.InvokeMember("Click");
26 SendKeys.Send("{ENTER}");
27 SendKeys.Flush();
28 }
29 catch (Exception er)
30 {
31 MessageBox.Show(er.ToString());
32 }
33 };
34 time.AutoReset = false;
35 time.Enabled = true;
36 }
37 }
38 }
1 foreach (HtmlElement item in doc.GetElementsByTagName("div"))
2 {
3 if (item.GetAttribute("className") == "detail_c")
4 {
5 dl.ShuLiang = item.Children[0].Children[3].OuterText;
6 }
7 }