jeudi 30 juillet 2015

C# Web Bot Not Working/Questions

I am trying to make a web bot that will click a button then fill out two textboxs with the contents of two text boxes (on gui of the program) and then click another button and have this repeat in the background of the program, but unfortunately it would not work so i unhid the web browser and made it big so i could see what the problem was like if any of the buttons were being clicked or the text boxs were filling out and none of the buttons were being clicked or anything

Help Please

`using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Instagram_Bot
{
    public partial class Form1 : MetroForm
    {
        public Form1()
        {
            InitializeComponent();
            webBrowser1.Navigate("http://iglikers.ml/");
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void startButton_Click(object sender, EventArgs e)
        {
            SendData();
        }

        private void SendData()
        {
            var buttons = webBrowser1.Document.GetElementsByTagName("button");

            foreach (HtmlElement button in buttons)
            {
                if (button.InnerText == " Get Free Followers")
                {
                    button.InvokeMember("click");
                }
            }
        }
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (webBrowser1.Url == e.Url)
            {
                if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
                {

                    webBrowser1.Document.GetElementById("lfFieldInputUsername").SetAttribute("value", userNameTextBox.Text);
                    webBrowser1.Document.GetElementById("lfFieldInputPassword").SetAttribute("value", passWordTextBox.Text);

                    var buttons = webBrowser1.Document.GetElementsByTagName("button");

                    foreach (HtmlElement button in buttons)
                    {
                        if (button.InnerText == " Log in")
                        {
                            button.InvokeMember("click");
                        }
                    }

                    SendData();
                }

            }
        }
    }
}
`




Aucun commentaire:

Enregistrer un commentaire