首页 > 解决方案 > 从 HTML 源代码中查找 HTML 元素

问题描述

所以我试图找到一个 HTML 元素,它是:

<a class="signout" href="https://www.dreamstime.com/logout.php">Sign out</a>

我的代码是:

 Dim thepage As String = postreqreader.ReadToEnd

                If thepage.Contains("<a href="https: //www.dreamstime.com/logout.php" class="signout">Sign out</a>") Then
                    good += 1
                    Label2.Text = "Good: " & good.ToString

                    If pencil = False Then
                        TextBox1.Text += currentaccount & vbNewLine
                        Me.Refresh()
                    End If

但是每次都会出现这个错误: OPEN ME

我尝试删除空格,但它一直出现错误说逗号,“)”,或预期的有效表达式延续。

标签: vb.net

解决方案


您没有正确地转义引号。"A" = A, "" = , """" = "

或者让使用 * 以便更容易看到,*"**,首先 * 表示开始,然后 " 你的字符,然后是另一个 *,所以它知道字符结束,并且 * 作为字符串的结尾。

在较长的字符串中,看起来像:

"some string ""is"" here"

这导致:

some string "is" here

推荐阅读