Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // create a new UdgerParser object
            UdgerParser parser = new UdgerParser(true);  // Development/Debug - debug info output to console

            //UdgerParser parser = new UdgerParser(); // Production

            // set data dir (this program must right write to cache dir)
            parser.SetDataDir(@"C:\tmp");

            // set You Accesskey (see https://udger.com/account/main)
            //parser.SetAccessKey("XXXXXX");
            // or download the datafile manually from http://data.udger.com/

            //If you want information about fragments
            parser.SetParseFragments(false); //for future use, now has no meaning


            //method "parse"
            var useragent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/8888 Chrome anonymized by Abelssoft 1085275131";
            // Gets information about the user agent
            Dictionary <string, object> aa = parser.parse(useragent);

            //method "isBot"
            useragent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
            //var ip = "100.43.81.130";
            Dictionary <string, object> bb = parser.isBot(useragent);

            useragent = "Mozilla/4.0 (compatible; MSIE ; Windows NT 6.0)";
            bb        = parser.isBot(useragent);

            //method "account"
            Dictionary <string, object> cc = parser.account();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Udger.Parser.UserAgent a;
            Udger.Parser.IPAddress i;

            // Create a new UdgerParser object
            UdgerParser parser = new UdgerParser();

            // Set data dir (in this directory is stored data file: udgerdb_v3.dat)
            // Data file can be downloaded manually from http://data.udger.com/, but we recommend use udger-updater
            parser.SetDataDir(@"C:\udger");
            //parser.SetDataDir(@"C:\udger", "udgerdb_v3-noip.dat ");

            // Set user agent and /or IP address
            parser.ua = @"Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13E238";
            parser.ip = "108.61.199.93";

            // Parse
            parser.parse();
            // Get information
            a = parser.userAgent;
            i = parser.ipAddress;


            parser.ua = @"Mozilla/5.0 (compatible; SeznamBot/3.2; +http://fulltext.sblog.cz/)";
            parser.ip = "2001:41d0:8:d950:0:0:0:1";
            parser.parse();
            a = parser.userAgent;
            i = parser.ipAddress;


            parser.ua = @"'&lorem>>'adasdad asd ";
            parser.ip = "lorem'bla?&";
            parser.parse();
            a = parser.userAgent;
            i = parser.ipAddress;

            parser.ua = @"Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53";
            parser.ip = "2001:41d0:8:d950::1";
            parser.parse();
            a = parser.userAgent;
            i = parser.ipAddress;


            parser.ip = "66.249.64.73";
            parser.parse();
            a = parser.userAgent;
            i = parser.ipAddress;


            parser.ua = @"Mozilla/5.0 (Playstation Vita 1.61) AppleWebKit/531.22.8 (KHTML, like Gecko) Silk/3.2";
            parser.ip = "90.177.52.111";
            parser.parse();
            a = parser.userAgent;
            i = parser.ipAddress;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string line;
            long   start_time, elapsed_time;

            Udger.Parser.UserAgent a;
            Udger.Parser.IPAddress i;
            WebClient    client;
            Stream       stream;
            StreamReader reader;


            Console.WriteLine("start");

            #region UdgerParse
            // Create a new UdgerParser object
            UdgerParser parser = new UdgerParser();

            // Set data dir (in this directory is stored data file: udgerdb_v3.dat)
            // Data file can be downloaded from http://data.udger.com/
            parser.SetDataDir(@"C:\udger");
            //parser.SetDataDir(@"C:\udger", "udgerdb_v3-noip.dat ");
            #endregion

            #region IP test
            Console.WriteLine("download test IP file start");
            client = new WebClient();
            stream = client.OpenRead("https://raw.githubusercontent.com/udger/test-data/master/test_ua-ip/ip_1000.txt");
            reader = new StreamReader(stream);
            Console.WriteLine("download test IP file end");


            Console.WriteLine("parse IP start");
            start_time = DateTime.Now.Ticks;

            while ((line = reader.ReadLine()) != null)
            {
                line      = line.Trim();
                parser.ip = line;
                // Parse
                parser.parse();
                i = parser.ipAddress;
            }


            elapsed_time = (DateTime.Now.Ticks - start_time) / 10;
            Console.WriteLine("parse IP end, time: " + elapsed_time);
            #endregion

            #region UA test
            Console.WriteLine("download test UA file start");
            client = new WebClient();
            stream = client.OpenRead("https://raw.githubusercontent.com/udger/test-data/master/test_ua-ip/ua_1000.txt");
            reader = new StreamReader(stream);
            Console.WriteLine("download test UA file end");


            Console.WriteLine("parse UA start");
            start_time = DateTime.Now.Ticks;

            while ((line = reader.ReadLine()) != null)
            {
                line      = line.Trim();
                parser.ua = line;
                // Parse
                parser.parse();
                a = parser.userAgent;
            }


            elapsed_time = (DateTime.Now.Ticks - start_time) / 10;
            Console.WriteLine("parse UA end, time: " + elapsed_time);
            #endregion

            Console.WriteLine("end");
            // Suspend the screen.
            Console.ReadLine();
        }