diff --git a/App.config b/App.config index 193aecc..51d9cf1 100644 --- a/App.config +++ b/App.config @@ -1,6 +1,18 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs deleted file mode 100644 index a0bdc3a..0000000 --- a/Form1.Designer.cs +++ /dev/null @@ -1,286 +0,0 @@ -namespace GtaVUsersInfo -{ - partial class MainForm - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором форм Windows - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - this.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.panel3 = new System.Windows.Forms.Panel(); - this.panel4 = new System.Windows.Forms.Panel(); - this.panel5 = new System.Windows.Forms.Panel(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.считатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.сохранитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.сохранитьКакToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.выйтиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.button1 = new System.Windows.Forms.Button(); - this.стилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.текстToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.цветаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.цветToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.стильToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.размерToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.леваяПанельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.праваяПанельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.центральнаяПанельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.верхнизToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.panel3.SuspendLayout(); - this.menuStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.Dock = System.Windows.Forms.DockStyle.Top; - this.panel1.Location = new System.Drawing.Point(0, 24); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(800, 20); - this.panel1.TabIndex = 0; - // - // panel2 - // - this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel2.Location = new System.Drawing.Point(0, 430); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(800, 20); - this.panel2.TabIndex = 1; - // - // panel3 - // - this.panel3.Controls.Add(this.button1); - this.panel3.Dock = System.Windows.Forms.DockStyle.Left; - this.panel3.Location = new System.Drawing.Point(0, 44); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(100, 386); - this.panel3.TabIndex = 2; - // - // panel4 - // - this.panel4.Dock = System.Windows.Forms.DockStyle.Right; - this.panel4.Location = new System.Drawing.Point(600, 44); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(200, 386); - this.panel4.TabIndex = 3; - // - // panel5 - // - this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel5.Location = new System.Drawing.Point(100, 44); - this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(500, 386); - this.panel5.TabIndex = 4; - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.файлToolStripMenuItem, - this.стилиToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(800, 24); - this.menuStrip1.TabIndex = 5; - this.menuStrip1.Text = "menuStrip1"; - // - // файлToolStripMenuItem - // - this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.считатьToolStripMenuItem, - this.сохранитьToolStripMenuItem, - this.сохранитьКакToolStripMenuItem, - this.toolStripSeparator1, - this.выйтиToolStripMenuItem}); - this.файлToolStripMenuItem.Name = "файлToolStripMenuItem"; - this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20); - this.файлToolStripMenuItem.Text = "Файл"; - // - // считатьToolStripMenuItem - // - this.считатьToolStripMenuItem.Name = "считатьToolStripMenuItem"; - this.считатьToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.считатьToolStripMenuItem.Text = "Открыть"; - // - // сохранитьToolStripMenuItem - // - this.сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem"; - this.сохранитьToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.сохранитьToolStripMenuItem.Text = "Сохранить"; - // - // сохранитьКакToolStripMenuItem - // - this.сохранитьКакToolStripMenuItem.Name = "сохранитьКакToolStripMenuItem"; - this.сохранитьКакToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.сохранитьКакToolStripMenuItem.Text = "Сохранить как"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); - // - // выйтиToolStripMenuItem - // - this.выйтиToolStripMenuItem.Name = "выйтиToolStripMenuItem"; - this.выйтиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.выйтиToolStripMenuItem.Text = "Выйти"; - // - // button1 - // - this.button1.Dock = System.Windows.Forms.DockStyle.Top; - this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.button1.Location = new System.Drawing.Point(0, 0); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(100, 23); - this.button1.TabIndex = 0; - this.button1.Text = "Автомобиль"; - this.button1.UseVisualStyleBackColor = true; - // - // стилиToolStripMenuItem - // - this.стилиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.текстToolStripMenuItem, - this.цветаToolStripMenuItem}); - this.стилиToolStripMenuItem.Name = "стилиToolStripMenuItem"; - this.стилиToolStripMenuItem.Size = new System.Drawing.Size(53, 20); - this.стилиToolStripMenuItem.Text = "Стили"; - // - // текстToolStripMenuItem - // - this.текстToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.цветToolStripMenuItem, - this.стильToolStripMenuItem, - this.размерToolStripMenuItem}); - this.текстToolStripMenuItem.Name = "текстToolStripMenuItem"; - this.текстToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.текстToolStripMenuItem.Text = "Текст"; - // - // цветаToolStripMenuItem - // - this.цветаToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.леваяПанельToolStripMenuItem, - this.праваяПанельToolStripMenuItem, - this.центральнаяПанельToolStripMenuItem, - this.верхнизToolStripMenuItem}); - this.цветаToolStripMenuItem.Name = "цветаToolStripMenuItem"; - this.цветаToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.цветаToolStripMenuItem.Text = "Цвета"; - // - // цветToolStripMenuItem - // - this.цветToolStripMenuItem.Name = "цветToolStripMenuItem"; - this.цветToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.цветToolStripMenuItem.Text = "Цвет"; - // - // стильToolStripMenuItem - // - this.стильToolStripMenuItem.Name = "стильToolStripMenuItem"; - this.стильToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.стильToolStripMenuItem.Text = "Стиль"; - // - // размерToolStripMenuItem - // - this.размерToolStripMenuItem.Name = "размерToolStripMenuItem"; - this.размерToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.размерToolStripMenuItem.Text = "Размер"; - // - // леваяПанельToolStripMenuItem - // - this.леваяПанельToolStripMenuItem.Name = "леваяПанельToolStripMenuItem"; - this.леваяПанельToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.леваяПанельToolStripMenuItem.Text = "Левая панель"; - // - // праваяПанельToolStripMenuItem - // - this.праваяПанельToolStripMenuItem.Name = "праваяПанельToolStripMenuItem"; - this.праваяПанельToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.праваяПанельToolStripMenuItem.Text = "Правая панель"; - // - // центральнаяПанельToolStripMenuItem - // - this.центральнаяПанельToolStripMenuItem.Name = "центральнаяПанельToolStripMenuItem"; - this.центральнаяПанельToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.центральнаяПанельToolStripMenuItem.Text = "Центральная панель"; - // - // верхнизToolStripMenuItem - // - this.верхнизToolStripMenuItem.Name = "верхнизToolStripMenuItem"; - this.верхнизToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.верхнизToolStripMenuItem.Text = "Верх/низ"; - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.panel5); - this.Controls.Add(this.panel4); - this.Controls.Add(this.panel3); - this.Controls.Add(this.panel2); - this.Controls.Add(this.panel1); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "MainForm"; - this.Text = "null"; - this.Load += new System.EventHandler(this.MainForm_Load); - this.panel3.ResumeLayout(false); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Panel panel4; - private System.Windows.Forms.Panel panel5; - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem файлToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem считатьToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem сохранитьToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem сохранитьКакToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem выйтиToolStripMenuItem; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.ToolStripMenuItem стилиToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem текстToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem цветToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem стильToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem размерToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem цветаToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem леваяПанельToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem праваяПанельToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem центральнаяПанельToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem верхнизToolStripMenuItem; - } -} - diff --git a/GtaVUsersInfo.csproj b/GtaVUsersInfo.csproj index f9104e7..cffbae8 100644 --- a/GtaVUsersInfo.csproj +++ b/GtaVUsersInfo.csproj @@ -12,6 +12,8 @@ 512 true true + + AnyCPU @@ -33,8 +35,42 @@ 4 + + packages\HtmlAgilityPack.1.11.67\lib\Net45\HtmlAgilityPack.dll + + + packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll + + + packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll + + + packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + @@ -44,18 +80,23 @@ + + packages\Selenium.WebDriver.4.25.0\lib\netstandard2.0\WebDriver.dll + - + + Form - - Form1.cs + + MainForm.cs + - - Form1.cs + + MainForm.cs ResXFileCodeGenerator @@ -66,6 +107,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs @@ -80,4 +122,11 @@ + + + + Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + + + \ No newline at end of file diff --git a/Helpers/CarParser.cs b/Helpers/CarParser.cs new file mode 100644 index 0000000..93f18b3 --- /dev/null +++ b/Helpers/CarParser.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; +using OpenQA.Selenium; +using OpenQA.Selenium.Firefox; +using OpenQA.Selenium.Support.UI; + +namespace GtaVUsersInfo.Helpers +{ + public class Car + { + public string Name { get; set; } + public int Price { get; set; } + public string Photo { get; set; } + public string Manufacturer { get; set; } + public string Class { get; set; } + public string Model { get; set; } + } + + public class CarParser : IDisposable + { + private IWebDriver driver; + + public CarParser() + { + var chromeOptions = new FirefoxOptions(); + chromeOptions.AddArgument("--no-sandbox"); + driver = new FirefoxDriver(chromeOptions); + } + + public async Task> ParseCarsFromPages(int maxPages) + { + var cars = new List(); + for (int page = 1; page <= maxPages; page++) + { + var url = $"https://gtacars.net/?page={page}"; + var pageCars = await ParseCarsFromPage(url); + cars.AddRange(pageCars); + } + return cars; + } + + private async Task> ParseCarsFromPage(string url) + { + var cars = new List(); + + // Открываем страницу в браузере + driver.Navigate().GoToUrl(url); + + // Ожидание, пока динамические элементы не подгрузятся + var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); + // Ждём, пока появится хотя бы один элемент с ценой + wait.Until(drv => drv.FindElements(By.CssSelector("span.v-popper--has-tooltip")).Any(e => e.Text.Contains("$"))); + IJavaScriptExecutor js = (IJavaScriptExecutor)driver; + Thread.Sleep(100); + js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight / 4);"); + Thread.Sleep(100); + js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight / 3);"); + Thread.Sleep(100); + js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight / 2);"); + Thread.Sleep(100); + js.ExecuteScript("window.scrollTo(0, document.body.scrollHeight);"); + Thread.Sleep(500); + + wait.Until(drv => drv.FindElements(By.CssSelector("img[src*='data:image/gif']")).Count == 0); + + // После этого можно парсить элементы + var carElements = driver.FindElements(By.CssSelector("div.relative.flex.flex-col")); + foreach (var carElement in carElements) + { + var car = new Car(); + + // Имя автомобиля + var nameElement = carElement.FindElement(By.CssSelector("span[title]")); + car.Name = nameElement.Text; + + // Цена автомобиля + var priceElement = carElement.FindElement(By.CssSelector("span.v-popper--has-tooltip")); + var priceText = priceElement.Text; + car.Price = ParsePrice(priceText); + + // Фото + var photoElement = carElement.FindElement(By.CssSelector("img.w-full")); + car.Photo = photoElement.GetAttribute("src"); + + // Производитель + var manufacturerElement = carElement.FindElement(By.CssSelector("a[href*='filter_manufacturer']")); + car.Manufacturer = manufacturerElement.Text; + + // Класс автомобиля + var classElement = carElement.FindElement(By.CssSelector("a[href*='filter_class']")); + car.Class = classElement.Text; + + // Модель (часть URL) + var modelElement = carElement.FindElement(By.CssSelector("a[href]")); + car.Model = modelElement.GetAttribute("href").Split('/').Last(); + + cars.Add(car); + } + + return cars; + } + + + private int ParsePrice(string priceText) + { + if (string.IsNullOrWhiteSpace(priceText)) return 0; + priceText = priceText.Replace("$", "").Replace(",", "").Replace(" ", ""); + return int.TryParse(priceText, out int price) ? price : 0; + } + + public void SaveToJson(List cars, string filePath) + { + var json = JsonConvert.SerializeObject(cars, Formatting.Indented); + File.WriteAllText(filePath, json); + } + + // Реализация метода Dispose + public void Dispose() + { + if (driver != null) + { + driver.Quit(); + driver.Dispose(); + } + } + } + + class Program + { + static async Task Main(string[] args) + { + using (var parser = new CarParser()) + { + var cars = await parser.ParseCarsFromPages(25); + parser.SaveToJson(cars, "cars.json"); + Console.WriteLine("Data saved to cars.json"); + } + } + } +} diff --git a/Helpers/Strings.cs b/Helpers/Strings.cs new file mode 100644 index 0000000..de06b31 --- /dev/null +++ b/Helpers/Strings.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GtaVUsersInfo.Helpers +{ + public class Strings + { + public readonly static string carUrl = "https://gtacars.net/"; + } +} diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs new file mode 100644 index 0000000..4863613 --- /dev/null +++ b/MainForm.Designer.cs @@ -0,0 +1,483 @@ +namespace GtaVUsersInfo +{ + partial class MainForm + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.buttonsPanel = new System.Windows.Forms.Panel(); + this.addCar = new System.Windows.Forms.Button(); + this.addParametrLabel = new System.Windows.Forms.Label(); + this.parametersPanel = new System.Windows.Forms.Panel(); + this.testPanel = new System.Windows.Forms.Panel(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.moneyPanel = new System.Windows.Forms.Panel(); + this.userMoney = new System.Windows.Forms.TextBox(); + this.userMoneyLabel = new System.Windows.Forms.Label(); + this.namePanel = new System.Windows.Forms.Panel(); + this.userName = new System.Windows.Forms.TextBox(); + this.userNameLabel = new System.Windows.Forms.Label(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.считатьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.сохранитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.сохранитьКакToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.выйтиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.стилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.текстToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.цветToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.стильToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.размерToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.цветаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.леваяПанельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.праваяПанельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.центральнаяПанельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.верхнизToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.splitterLeft = new System.Windows.Forms.Splitter(); + this.splitterRigth = new System.Windows.Forms.Splitter(); + this.carsPanel = new System.Windows.Forms.Panel(); + this.parserButton = new System.Windows.Forms.Button(); + this.buttonsPanel.SuspendLayout(); + this.parametersPanel.SuspendLayout(); + this.testPanel.SuspendLayout(); + this.moneyPanel.SuspendLayout(); + this.namePanel.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Location = new System.Drawing.Point(0, 24); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(752, 20); + this.panel1.TabIndex = 0; + // + // panel2 + // + this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 463); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(752, 20); + this.panel2.TabIndex = 1; + // + // buttonsPanel + // + this.buttonsPanel.AutoScroll = true; + this.buttonsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.buttonsPanel.Controls.Add(this.parserButton); + this.buttonsPanel.Controls.Add(this.addCar); + this.buttonsPanel.Controls.Add(this.addParametrLabel); + this.buttonsPanel.Dock = System.Windows.Forms.DockStyle.Left; + this.buttonsPanel.Location = new System.Drawing.Point(0, 44); + this.buttonsPanel.MinimumSize = new System.Drawing.Size(100, 100); + this.buttonsPanel.Name = "buttonsPanel"; + this.buttonsPanel.Size = new System.Drawing.Size(100, 419); + this.buttonsPanel.TabIndex = 2; + // + // addCar + // + this.addCar.AutoSize = true; + this.addCar.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.addCar.Dock = System.Windows.Forms.DockStyle.Top; + this.addCar.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.addCar.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.addCar.Location = new System.Drawing.Point(0, 13); + this.addCar.Name = "addCar"; + this.addCar.Size = new System.Drawing.Size(98, 26); + this.addCar.TabIndex = 2; + this.addCar.Text = "Автомобиль"; + this.addCar.UseVisualStyleBackColor = true; + // + // addParametrLabel + // + this.addParametrLabel.AutoSize = true; + this.addParametrLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.addParametrLabel.Location = new System.Drawing.Point(0, 0); + this.addParametrLabel.Name = "addParametrLabel"; + this.addParametrLabel.Size = new System.Drawing.Size(60, 13); + this.addParametrLabel.TabIndex = 1; + this.addParametrLabel.Text = "Добавить:"; + // + // parametersPanel + // + this.parametersPanel.AutoScroll = true; + this.parametersPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.parametersPanel.Controls.Add(this.testPanel); + this.parametersPanel.Controls.Add(this.moneyPanel); + this.parametersPanel.Controls.Add(this.namePanel); + this.parametersPanel.Dock = System.Windows.Forms.DockStyle.Right; + this.parametersPanel.Location = new System.Drawing.Point(552, 44); + this.parametersPanel.MinimumSize = new System.Drawing.Size(100, 100); + this.parametersPanel.Name = "parametersPanel"; + this.parametersPanel.Size = new System.Drawing.Size(200, 419); + this.parametersPanel.TabIndex = 3; + // + // testPanel + // + this.testPanel.AutoSize = true; + this.testPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.testPanel.Controls.Add(this.textBox1); + this.testPanel.Controls.Add(this.label1); + this.testPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.testPanel.Location = new System.Drawing.Point(0, 74); + this.testPanel.Name = "testPanel"; + this.testPanel.Padding = new System.Windows.Forms.Padding(2); + this.testPanel.Size = new System.Drawing.Size(198, 37); + this.testPanel.TabIndex = 3; + // + // textBox1 + // + this.textBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox1.Location = new System.Drawing.Point(2, 15); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(194, 20); + this.textBox1.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(2, 2); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(48, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Деньги:"; + // + // moneyPanel + // + this.moneyPanel.AutoSize = true; + this.moneyPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.moneyPanel.Controls.Add(this.userMoney); + this.moneyPanel.Controls.Add(this.userMoneyLabel); + this.moneyPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.moneyPanel.Location = new System.Drawing.Point(0, 37); + this.moneyPanel.Name = "moneyPanel"; + this.moneyPanel.Padding = new System.Windows.Forms.Padding(2); + this.moneyPanel.Size = new System.Drawing.Size(198, 37); + this.moneyPanel.TabIndex = 2; + // + // userMoney + // + this.userMoney.Dock = System.Windows.Forms.DockStyle.Top; + this.userMoney.Location = new System.Drawing.Point(2, 15); + this.userMoney.Multiline = true; + this.userMoney.Name = "userMoney"; + this.userMoney.Size = new System.Drawing.Size(194, 20); + this.userMoney.TabIndex = 1; + // + // userMoneyLabel + // + this.userMoneyLabel.AutoSize = true; + this.userMoneyLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.userMoneyLabel.Location = new System.Drawing.Point(2, 2); + this.userMoneyLabel.Name = "userMoneyLabel"; + this.userMoneyLabel.Size = new System.Drawing.Size(48, 13); + this.userMoneyLabel.TabIndex = 0; + this.userMoneyLabel.Text = "Деньги:"; + // + // namePanel + // + this.namePanel.AutoSize = true; + this.namePanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.namePanel.Controls.Add(this.userName); + this.namePanel.Controls.Add(this.userNameLabel); + this.namePanel.Dock = System.Windows.Forms.DockStyle.Top; + this.namePanel.Location = new System.Drawing.Point(0, 0); + this.namePanel.Name = "namePanel"; + this.namePanel.Padding = new System.Windows.Forms.Padding(2); + this.namePanel.Size = new System.Drawing.Size(198, 37); + this.namePanel.TabIndex = 1; + // + // userName + // + this.userName.Dock = System.Windows.Forms.DockStyle.Top; + this.userName.Location = new System.Drawing.Point(2, 15); + this.userName.Multiline = true; + this.userName.Name = "userName"; + this.userName.Size = new System.Drawing.Size(194, 20); + this.userName.TabIndex = 1; + // + // userNameLabel + // + this.userNameLabel.AutoSize = true; + this.userNameLabel.Dock = System.Windows.Forms.DockStyle.Top; + this.userNameLabel.Location = new System.Drawing.Point(2, 2); + this.userNameLabel.Name = "userNameLabel"; + this.userNameLabel.Size = new System.Drawing.Size(32, 13); + this.userNameLabel.TabIndex = 0; + this.userNameLabel.Text = "Имя:"; + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.файлToolStripMenuItem, + this.стилиToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(752, 24); + this.menuStrip1.TabIndex = 5; + this.menuStrip1.Text = "menuStrip1"; + // + // файлToolStripMenuItem + // + this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.считатьToolStripMenuItem, + this.сохранитьToolStripMenuItem, + this.сохранитьКакToolStripMenuItem, + this.toolStripSeparator1, + this.выйтиToolStripMenuItem}); + this.файлToolStripMenuItem.Name = "файлToolStripMenuItem"; + this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20); + this.файлToolStripMenuItem.Text = "Файл"; + // + // считатьToolStripMenuItem + // + this.считатьToolStripMenuItem.Name = "считатьToolStripMenuItem"; + this.считатьToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.считатьToolStripMenuItem.Text = "Открыть"; + // + // сохранитьToolStripMenuItem + // + this.сохранитьToolStripMenuItem.Name = "сохранитьToolStripMenuItem"; + this.сохранитьToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.сохранитьToolStripMenuItem.Text = "Сохранить"; + // + // сохранитьКакToolStripMenuItem + // + this.сохранитьКакToolStripMenuItem.Name = "сохранитьКакToolStripMenuItem"; + this.сохранитьКакToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.сохранитьКакToolStripMenuItem.Text = "Сохранить как"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(151, 6); + // + // выйтиToolStripMenuItem + // + this.выйтиToolStripMenuItem.Name = "выйтиToolStripMenuItem"; + this.выйтиToolStripMenuItem.Size = new System.Drawing.Size(154, 22); + this.выйтиToolStripMenuItem.Text = "Выйти"; + // + // стилиToolStripMenuItem + // + this.стилиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.текстToolStripMenuItem, + this.цветаToolStripMenuItem}); + this.стилиToolStripMenuItem.Name = "стилиToolStripMenuItem"; + this.стилиToolStripMenuItem.Size = new System.Drawing.Size(53, 20); + this.стилиToolStripMenuItem.Text = "Стили"; + // + // текстToolStripMenuItem + // + this.текстToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.цветToolStripMenuItem, + this.стильToolStripMenuItem, + this.размерToolStripMenuItem}); + this.текстToolStripMenuItem.Name = "текстToolStripMenuItem"; + this.текстToolStripMenuItem.Size = new System.Drawing.Size(106, 22); + this.текстToolStripMenuItem.Text = "Текст"; + // + // цветToolStripMenuItem + // + this.цветToolStripMenuItem.Name = "цветToolStripMenuItem"; + this.цветToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.цветToolStripMenuItem.Text = "Цвет"; + // + // стильToolStripMenuItem + // + this.стильToolStripMenuItem.Name = "стильToolStripMenuItem"; + this.стильToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.стильToolStripMenuItem.Text = "Стиль"; + // + // размерToolStripMenuItem + // + this.размерToolStripMenuItem.Name = "размерToolStripMenuItem"; + this.размерToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.размерToolStripMenuItem.Text = "Размер"; + // + // цветаToolStripMenuItem + // + this.цветаToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.леваяПанельToolStripMenuItem, + this.праваяПанельToolStripMenuItem, + this.центральнаяПанельToolStripMenuItem, + this.верхнизToolStripMenuItem}); + this.цветаToolStripMenuItem.Name = "цветаToolStripMenuItem"; + this.цветаToolStripMenuItem.Size = new System.Drawing.Size(106, 22); + this.цветаToolStripMenuItem.Text = "Цвета"; + // + // леваяПанельToolStripMenuItem + // + this.леваяПанельToolStripMenuItem.Name = "леваяПанельToolStripMenuItem"; + this.леваяПанельToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.леваяПанельToolStripMenuItem.Text = "Левая панель"; + // + // праваяПанельToolStripMenuItem + // + this.праваяПанельToolStripMenuItem.Name = "праваяПанельToolStripMenuItem"; + this.праваяПанельToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.праваяПанельToolStripMenuItem.Text = "Правая панель"; + // + // центральнаяПанельToolStripMenuItem + // + this.центральнаяПанельToolStripMenuItem.Name = "центральнаяПанельToolStripMenuItem"; + this.центральнаяПанельToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.центральнаяПанельToolStripMenuItem.Text = "Центральная панель"; + // + // верхнизToolStripMenuItem + // + this.верхнизToolStripMenuItem.Name = "верхнизToolStripMenuItem"; + this.верхнизToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.верхнизToolStripMenuItem.Text = "Верх/низ"; + // + // splitterLeft + // + this.splitterLeft.Location = new System.Drawing.Point(100, 44); + this.splitterLeft.Name = "splitterLeft"; + this.splitterLeft.Size = new System.Drawing.Size(5, 419); + this.splitterLeft.TabIndex = 6; + this.splitterLeft.TabStop = false; + // + // splitterRigth + // + this.splitterRigth.Dock = System.Windows.Forms.DockStyle.Right; + this.splitterRigth.Location = new System.Drawing.Point(547, 44); + this.splitterRigth.Name = "splitterRigth"; + this.splitterRigth.Size = new System.Drawing.Size(5, 419); + this.splitterRigth.TabIndex = 7; + this.splitterRigth.TabStop = false; + // + // carsPanel + // + this.carsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.carsPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.carsPanel.Location = new System.Drawing.Point(105, 44); + this.carsPanel.MinimumSize = new System.Drawing.Size(300, 100); + this.carsPanel.Name = "carsPanel"; + this.carsPanel.Size = new System.Drawing.Size(442, 419); + this.carsPanel.TabIndex = 8; + // + // parserButton + // + this.parserButton.AutoSize = true; + this.parserButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.parserButton.Dock = System.Windows.Forms.DockStyle.Bottom; + this.parserButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.parserButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.parserButton.Location = new System.Drawing.Point(0, 395); + this.parserButton.Name = "parserButton"; + this.parserButton.Size = new System.Drawing.Size(98, 22); + this.parserButton.TabIndex = 3; + this.parserButton.Text = "Парсинг"; + this.parserButton.UseVisualStyleBackColor = true; + this.parserButton.Click += new System.EventHandler(this.parserButton_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(752, 483); + this.Controls.Add(this.carsPanel); + this.Controls.Add(this.splitterRigth); + this.Controls.Add(this.splitterLeft); + this.Controls.Add(this.parametersPanel); + this.Controls.Add(this.buttonsPanel); + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.MinimumSize = new System.Drawing.Size(526, 365); + this.Name = "MainForm"; + this.Text = "null"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.buttonsPanel.ResumeLayout(false); + this.buttonsPanel.PerformLayout(); + this.parametersPanel.ResumeLayout(false); + this.parametersPanel.PerformLayout(); + this.testPanel.ResumeLayout(false); + this.testPanel.PerformLayout(); + this.moneyPanel.ResumeLayout(false); + this.moneyPanel.PerformLayout(); + this.namePanel.ResumeLayout(false); + this.namePanel.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel buttonsPanel; + private System.Windows.Forms.Panel parametersPanel; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem файлToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem считатьToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem сохранитьToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem сохранитьКакToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem выйтиToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem стилиToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem текстToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem цветToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem стильToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem размерToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem цветаToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem леваяПанельToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem праваяПанельToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem центральнаяПанельToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem верхнизToolStripMenuItem; + private System.Windows.Forms.Panel moneyPanel; + private System.Windows.Forms.TextBox userMoney; + private System.Windows.Forms.Label userMoneyLabel; + private System.Windows.Forms.Panel namePanel; + private System.Windows.Forms.TextBox userName; + private System.Windows.Forms.Label userNameLabel; + private System.Windows.Forms.Panel testPanel; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button addCar; + private System.Windows.Forms.Label addParametrLabel; + private System.Windows.Forms.Splitter splitterLeft; + private System.Windows.Forms.Splitter splitterRigth; + private System.Windows.Forms.Panel carsPanel; + private System.Windows.Forms.Button parserButton; + } +} + diff --git a/Form1.cs b/MainForm.cs similarity index 54% rename from Form1.cs rename to MainForm.cs index 34b14c5..4382c08 100644 --- a/Form1.cs +++ b/MainForm.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using GtaVUsersInfo.Helpers; namespace GtaVUsersInfo { @@ -19,7 +20,17 @@ namespace GtaVUsersInfo private void MainForm_Load(object sender, EventArgs e) { + + } + async private void parserButton_Click(object sender, EventArgs e) + { + using (var parser = new CarParser()) + { + var cars = await parser.ParseCarsFromPages(25); + parser.SaveToJson(cars, "cars.json"); + Console.WriteLine("Data saved to cars.json"); + } } } } diff --git a/Form1.resx b/MainForm.resx similarity index 100% rename from Form1.resx rename to MainForm.resx diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..02b2fcf --- /dev/null +++ b/packages.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file