C# C不能按他的ID点击网站按钮

C# C不能按他的ID点击网站按钮,c#,web,server,htmlbutton,C#,Web,Server,Htmlbutton,我有一个问题,我不知道它来自哪里。这和点击他的ID按钮有关。有人能解释一下发生了什么事吗? 这是为了比较来自客户机的消息,如果该消息是正确的,它将单击该按钮,但由于某些原因,它不起作用 Img: C代码 namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); webB

我有一个问题,我不知道它来自哪里。这和点击他的ID按钮有关。有人能解释一下发生了什么事吗? 这是为了比较来自客户机的消息,如果该消息是正确的,它将单击该按钮,但由于某些原因,它不起作用

Img:

C代码

    namespace WindowsFormsApplication2
{


public partial class Form1 : Form
{
    public Form1()
    {

        InitializeComponent();
        webBrowser1.Navigate("http://kissanime.com/Anime/One-Piece/Episode-692");

        System.Threading.Thread newThread = new System.Threading.Thread(serverfunction);
        newThread.Start();


    }
    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {

    }


   public void serverfunction()
        {
            int port = 80;
            IPAddress localAddr = IPAddress.Parse("192.168.1.68");
            TcpListener server = new TcpListener(localAddr, port);

            server.Start();


            byte[] bytes = new byte[2048];
            string data;


            while (true)
            {
                TcpClient client = server.AcceptTcpClient();
                NetworkStream stream = client.GetStream();
                int i;
                i = stream.Read(bytes, 0, bytes.Length);
                data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                Global.message = StripExtended(data);
                if (Global.message == "NxEpisode")
                {
                                        webBrowser1.Document.GetElementById("btnNext").InvokeMember("Click");
                }

                }

        }

    static string StripExtended(string arg)
    {
        StringBuilder buffer = new StringBuilder(arg.Length); //Max length
        foreach (char ch in arg)
        {
            UInt16 num = Convert.ToUInt16(ch);//In .NET, chars are UTF-16
            //The basic characters have the same code points as ASCII, and the extended characters are bigger
            if ((num >= 32u) && (num <= 126u)) buffer.Append(ch);
        }
        return buffer.ToString();
    }





}


    public class Global
    {
        public static string message = "";

    } 





}
Html代码

    <a href="http://kissanime.com/Anime/One-Piece/Episode-692?id=108094">
<img id='btnNext' src="http://kissanime.com/Content/images/next.png" title="Next episode" border="0"/></a>

我真的不知道是什么原因导致它无法工作,但请尝试以下方法:

<img id='btnNext' name='btnNext' src="http://kissanime.com/Content/images/next.png" title="Next episode" border="0"/></a>

请具体说明它是如何起作用的。我想我是非常具体的
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("img"))
            {
                if (el.Name == "btnNext")
                {
                    el.InvokeMember("Click");
                }
            }