29 Aralık 2015 Salı

c# form doldurma

public Form1()
{
    InitializeComponent();
}
 
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    if (e.Url.AbsolutePath != (sender as WebBrowser).Url.AbsolutePath)
        return; 
}
 
private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.Navigate("https://profil.wp.pl/rejestracja.html");
}
 
private void button1_Click(object sender, EventArgs e)
{
    string url;
    HtmlElementCollection theElementCollection;
    theElementCollection = webBrowser1.Document.GetElementsByTagName("img");
    foreach (HtmlElement curElement in theElementCollection)
    {
        if (curElement.GetAttribute("src").ToString().Contains("https://si.wp.pl/captcha?"))
        {
            url = curElement.GetAttribute("src").ToString();
            pictureBox1.Load(url);
        }
    }
    webBrowser1.Document.GetElementById("firstName").SetAttribute("value", imie);
    webBrowser1.Document.GetElementById("lastName").SetAttribute("value", nazwisko);
    webBrowser1.Document.GetElementById("plec-mężczyzna").InvokeMember("click");
    webBrowser1.Document.GetElementById("birthDateDay").SetAttribute("value", dzien2);
    webBrowser1.Document.GetElementById("birthDateMonth").SetAttribute("value", miesiac2);
    webBrowser1.Document.GetElementById("birthDateYear").SetAttribute("value", rok2);
    webBrowser1.Document.GetElementById("login").SetAttribute("value", imie + nazwisko);
    webBrowser1.Document.GetElementById("darmowa").InvokeMember("click");
    webBrowser1.Document.GetElementById("cloudAccount").InvokeMember("click");
    webBrowser1.Document.GetElementById("password").SetAttribute("value", haslo);
    webBrowser1.Document.GetElementById("passwordRepeat").SetAttribute("value", haslo);            
    webBrowser1.Document.GetElementById("helperEmail").SetAttribute("value", email + "@wp.pl");
    webBrowser1.Document.GetElementById("citySize").SetAttribute("value", "1");
    webBrowser1.Document.GetElementById("education").SetAttribute("value", "1");
    webBrowser1.Document.GetElementById("job").SetAttribute("value", "1");
    webBrowser1.Document.GetElementById("zgodaTerms").InvokeMember("click");
}
 
private void button2_Click(object sender, EventArgs e)
{
    webBrowser1.Document.GetElementById("captchaCode").SetAttribute("value", textBox1.Text);
    webBrowser1.Document.GetElementById("btnSubmit").InvokeMember("click");
    richTextBox1.AppendText("L: " + imie + nazwisko + "@wp.pl" + "\n");
    richTextBox1.AppendText("P: " + haslo +"\n");
    richTextBox1.AppendText("\n");
}