.Net:C#实现百度自动搜索

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IE
{
    public partial class Form1 : Form
    {
        private bool ie_Read = false;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer();
            ie.DocumentComplete += ie_DocumentComplete;
            ie.Navigate("http://www.baidu.com");
            ie.Visible = true;
            compWait();
            mshtml.HTMLDocument doc = ie.Document;
            doc.getElementById("kw").innerText = "c#";
            doc.getElementById("su").click(); .
        }
        private void ie_DocumentComplete(object pDisp, ref object URL)
        {
            ie_Read = true;
        }
        private void compWait()
        {
            while (ie_Read != true)
            {
                Application.DoEvents();
            }
        } 
    }
}

爬虫:https://blog.csdn.net/qq_32740675/article/details/79720367

猜你喜欢

转载自blog.csdn.net/wangqianqianya/article/details/88530444