Пример #1
0
        static void Start(MOD operation)
        {
            switch (operation)
            {
            case MOD.persMessage:               //pers. message mod creates standart constructor and launches spam
            {
                seleniumHundler hundler = new seleniumHundler(login, pass, text, timer);
                hundler.navTo();
                break;
            }

            case MOD.comMessage:         //spam to groups
            {
                int count;               //enter int values of cycles
                do                       //every time we'll change link and repeat spam
                {
                    Console.WriteLine("how many groups you will spam?\tcount: {1..6}\ncount = ");
                    count = Convert.ToInt32(Console.ReadLine());
                }while (count > MaxLinks || count <= 0);
                Xmlelement[] elmnt     = new Xmlelement[count];            //struct contains 2 params (link & int count of comments)
                xmlParser    xmlParser = new xmlParser("XMLFile_1.xml");   //create struct for reading from xml file
                Thread.Sleep(1000);
                for (int i = 0; i < count; i++)                            //initialize vector from xml file
                {
                    elmnt[i] = xmlParser.GetLink(i.ToString());
                    Console.WriteLine($"Link: {elmnt[i].link} Count: {elmnt[i].count}");
                }

                Console.WriteLine("Just wait a while...");
                Thread.Sleep(1000);
                seleniumHundler hundler = new seleniumHundler(login, pass, text, timer, elmnt);             //create overloaded constructor
                break;
            }

            default:
            {
                Console.WriteLine("Exception in started data");
                break;
            }
            }
        }
Пример #2
0
        public Xmlelement GetLink(string attr)
        {
            Xmlelement  element;
            XmlDocument linksDoc = new XmlDocument();

            linksDoc.Load(textFile);
            XmlElement xmlElement = linksDoc.DocumentElement;

            foreach (XmlNode nodeName in xmlElement)
            {
                if (nodeName.Attributes.Count > 0 && nodeName.Attributes[0].Value == attr)
                {
                    string link  = nodeName["link"].InnerText;
                    int    count = int.Parse(nodeName["count"].InnerText);
                    element = new Xmlelement(link, count);
                    return(element);
                }
            }
            element = new Xmlelement("", 0);
            return(element);
        }