Ejemplo n.º 1
0
        private void GetUsersInfo_Click(object sender, EventArgs e)
        {
            AutoriaParser parser = new AutoriaParser();

            Random rnd = new Random();

            List<UserInfo> userInfos = new List<UserInfo>();

            for (int i = 0; i < 100; i++)
            {
                int id = rnd.Next(1, 5150000);
                Uri uri = new Uri("https://auto.ria.com/demo/bu/finalPage/users/" + id + "/_extended");

                string responseText = parser.GetSearchResults(uri);

                UserInfo userInfo;
                try
                {
                    userInfo = JsonConvert.DeserializeObject<UserInfo>(responseText);
                }
                catch (JsonSerializationException exception)
                {
                    Console.WriteLine("error:" + id);
                    continue;
                }

                userInfos.Add(userInfo);

                /*

                StringBuilder phoneString = new StringBuilder("/");
                foreach (var phone in userInfo?.phones)
                {
                    phoneString.Append(phone.phone_formatted);
                    phoneString.Append("/");
                }

                string email = userInfo?.user?.email_normalized;

                string name = userInfo?.user?.name;

                Console.WriteLine("id: {0}; name: {1}; email:{2}; phone: {3}", id, name, email, phoneString);
                */
            }

            using (var db = new AutoRiaContext())
            {
                db.UserInfos.AddRange(userInfos);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 private void GetAllAds_Click(object sender, EventArgs e)
 {
     AutoriaParser parser = new AutoriaParser();
     List<AutoInfo> adsList = parser.GetAllAds(_mChromeBrowser.Address);
 }