Select field in Webbrowser

Asked

Viewed 120 times

1

  • Do you want, in the select you have at the bottom of the page, to choose the correct 8080 ? has a difficulty there that the element has no id or name but we will try

  • You want to copy the ip on the line where port 8080 is to a string?

  • That’s right. I want to use select at the bottom of the page and choose port 8080.

1 answer

0

I was able to select the amount you need, despite the select do not have id, I made a "Pog" to validate by InnerText but, the site has not yet applied the selected value to the list, I could not identify what triggers the filter.

Follows the code:

public partial class Form3 : Form
{
    public Form3()
    {
        InitializeComponent();
    }

    private void Form3_Load(object sender, EventArgs e)
    {
        webBrowser1.Navigate("https://free-proxy-list.net/");
    }

    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        var colecao = ((WebBrowser)sender).Document.All.Cast<HtmlElement>().ToList();
        HtmlElement elemento = colecao.Find(p => p.TagName.ToLower() == "select" && p.InnerText.StartsWith("All"));
        elemento.SetAttribute("value", "8080");
    }
}
  • didn’t work here. Gave error "Additional information: Object reference not set for an instance of an object." Setattribute("value", "8080");

  • puts to debug, a breakpoint, and see if the variable "element" is not null... check the Wb event, it has to be the "documentCompleted"

  • Code changed, here also had stopped working, try again

  • the variable "element" is null

  • Now the combo appears selected with "8080", but does not apply the filter

  • yes, that’s what I wrote and I couldn’t do, because I couldn’t find the one that shoots the filter

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.