简体   繁体   中英

VB.NET How to enter text into a website textbox without a “value” attribute

I am making a program that finds the source URL of a video from the website, www.clicktoview.org. I can download the captcha it requires, and display it, but I can't solve it with the user's input because the text box on the website doesn't have a value="" attribute.

Here is the relevant part of the HTML code:

<input type="text" id="recaptcha_response_field" name="recaptcha_response_field">

With this hindrance, is there any way I can input the user's captcha interpretation to the text field?

My code would be

WebBrowser1.Document.GetElementById("recaptcha_response_field").SetAttribute("value", TextBox2.Text)

but there isn't a value attribute.

NB The website is http://clicktoview.org/jbs2xyb89uai

Thanks for any help!

There isn't anything wrong with your code.

WebBrowser1.Document.GetElementById("recaptcha_response_field").SetAttribute("value", TextBox2.Text)

should do what you want. Even if a htmlElement doens't have a written value="" field you could still set it.

Have you checked to see that the GetElementById("recaptcha_response_field") returns a valid htmlElement?

            Dim htmlElement As HtmlElement = WebBrowser1.Document.GetElementById("recaptcha_response_field")
            If htmlElement IsNot Nothing Then
                htmlElement.SetAttribute("value",TextBox2.Text)
            End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM