基本信息
源码名称:C# 浏览器爬虫页面控制后台抓取
源码大小:793.41M
文件格式:.rar
开发语言:C#
更新时间:2024-09-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 10 元 
   源码介绍

C# 浏览器爬虫页面控制后台抓取

使用的winform创建的一个浏览器,并在里面操作H5页面
主要使用cefSharp创建一个浏览器框架,并在此框架自动控制浏览页面
可以通过框架实现C#和JS的相互调用
可以实时抓取网页后台api通信数据,方便二次开发

/// <summary>
///解析按钮点击
///
/// <summary>
private void Button2_Click(object sender, EventArgs e)
{
    //htmlDocument.GetElementById("kw").SetAttribute("value", "success");

    // 这里是location方法 获取的位置
    int x = 789; // X coordinate of the click
    int y = 238; // Y coordinate of the click
    IntPtr handle = webBrowser1.Handle;
    StringBuilder className = new StringBuilder(789);
    while (className.ToString() != "Internet Explorer_Server") // The class control for the browser
    {
        handle = GetWindow(handle, 5); // Get a handle to the child window
        GetClassName(handle, className, className.Capacity);
    }

    IntPtr lParam = (IntPtr)((y << 16) | x); // The coordinates
    IntPtr wParam = IntPtr.Zero; // Additional parameters for the click (e.g. Ctrl)
    const uint downCode = 0x201; // Left click down code
    const uint upCode = 0x202; // Left click up code
    SendMessage(handle, downCode, wParam, lParam); // Mouse button down
    SendMessage(handle, upCode, wParam, lParam); // Mouse button up
}