示例#1
0
        public List <ScrappedAdress> getScrappedAdresses(string siteAdress, string tagPath)
        {
            string[] splitedTags = splitTags(tagPath);

            HtmlWeb web     = new HtmlWeb();
            var     htmlDoc = web.Load(siteAdress);

            StringBuilder         sb    = new StringBuilder();
            List <ScrappedAdress> aList = new List <ScrappedAdress>();
            HtmlNodeCollection    node  = htmlDoc.DocumentNode.SelectNodes("//" + splitedTags[splitedTags.Length - 3]);

            for (int i = 0; i < aList.Count; i++)
            {
                Console.WriteLine($"Country: {aList[i].Country} \nAdress: {aList[i].ConnectionAdress} \nPort: {aList[i].Port}\n");
            }

            foreach (var tagNode in node.Descendants(splitedTags[splitedTags.Length - 2]))
            {
                ScrappedAdressBuilder sab = new ScrappedAdressBuilder();
                foreach (var tag in tagNode.Descendants(splitedTags[splitedTags.Length - 1]))
                {
                    if (tag.NodeType == HtmlNodeType.Element)
                    {
                        sab.FilterPart(tag);
                    }
                }
                ScrappedAdress sa = (ScrappedAdress)sab.buildScrappedObject();
                if (sa.Country != "" && sa.Country != null)
                {
                    aList.Add(sa);
                }
            }
            FilesIO.serializeList("serList", aList);
            return(aList);
        }
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            var aList = new ConnectionController().getScrappedAdresses(FilesIO.getStringFromFile("proxyListSite.txt", "E:\\"), "tbody /tr/td");

            /*
             * for (int i = 0; i < aList.Count; i++)
             * {
             *  Console.WriteLine($"Country: {aList[i].Country} \nAdress: {aList[i].ConnectionAdress} \nPort: {aList[i].Port}\n");
             * }*///TODO Check empty IP

            TelegramBotController telegram = new TelegramBotController(aList);

            telegram.connect();
        }
示例#3
0
        public static void SimpleTelegramBot()
        {
            var aList = new ConnectionController().getScrappedAdresses(FilesIO.getStringFromFile("proxyListSite.txt", "E:\\"), "tbody/tr/td");

            for (int i = 0; i < aList.Count; i++)
            {
                Console.WriteLine($"Country: {aList[i].Country} \nAdress: {aList[i].ConnectionAdress} \nPort: {aList[i].Port}\n");
            }

            TelegramBotController telegram = new TelegramBotController(aList);

            telegram.connect();

            Console.ReadLine();
        }
示例#4
0
 public TelegramBotController(List <ScrappedAdress> scrappedAdresses)
 {
     this.scrappedAdresses = scrappedAdresses;
     this.token            = FilesIO.getStringFromFile("adress.txt", "E:\\");
 }