柒夏桑 2018-06-27 08:54 采纳率: 0%
浏览 1877
已结题

c#怎么获取网页上title的值

我想获取打开网站上的title的值“正式受理”,并将这个值写入Excel,应该怎么做,请各位大神赐教
图片说明

这是我写的代码


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

namespace MyAutoM
{
public partial class Form1 : Form
{

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        //检测是否打开指定网页
        mshtml.HTMLDocument doc = getInternetExploer("http://135.64.132.8").Document;

        //获取title的值“正式受理”,请各位大神帮我补充一下

    }
     public static SHDocVw.InternetExplorer getInternetExploer(string url)
    {
        var shell = new Shell32.Shell();
        var windows = (SHDocVw.IShellWindows)shell.Windows();
        SHDocVw.InternetExplorer ie;
        foreach (object window in windows)
        {
            ie = window as SHDocVw.InternetExplorer;
            if (ie != null &&
                    string.Equals(System.IO.Path.GetFileName(ie.FullName),
                    "iexplore.exe", StringComparison.CurrentCultureIgnoreCase))
            {
                if (ie.LocationURL == url)
                {
                    return ie;
                }
            }
        }
        return null;
    }
}

}

  • 写回答

6条回答 默认 最新

  • Go 旅城通票 2018-06-27 12:09
    关注

    干嘛不用webrequest直接下载iframe加载的页面,前后前后截取下就行了

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置