Добавлен парсер атвомобилей

This commit is contained in:
MisterMLiL 2024-10-06 14:05:10 +03:00
parent f1046652f5
commit 493f3ddbf4
9 changed files with 734 additions and 292 deletions

View File

@ -3,4 +3,16 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.4" newVersion="8.0.0.4" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> </configuration>

286
Form1.Designer.cs generated
View File

@ -1,286 +0,0 @@
namespace GtaVUsersInfo
{
partial class MainForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
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;
}
}

View File

@ -12,6 +12,8 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -33,8 +35,42 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.11.67.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>packages\HtmlAgilityPack.1.11.67\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -44,18 +80,23 @@
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WebDriver, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Selenium.WebDriver.4.25.0\lib\netstandard2.0\WebDriver.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Form1.cs"> <Compile Include="Helpers\Strings.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Form1.Designer.cs"> <Compile Include="MainForm.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Helpers\CarParser.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="MainForm.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
@ -66,6 +107,7 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -80,4 +122,11 @@
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Selenium.WebDriver.4.25.0\build\Selenium.WebDriver.targets" Condition="Exists('packages\Selenium.WebDriver.4.25.0\build\Selenium.WebDriver.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Selenium.WebDriver.4.25.0\build\Selenium.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Selenium.WebDriver.4.25.0\build\Selenium.WebDriver.targets'))" />
</Target>
</Project> </Project>

145
Helpers/CarParser.cs Normal file
View File

@ -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<List<Car>> ParseCarsFromPages(int maxPages)
{
var cars = new List<Car>();
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<List<Car>> ParseCarsFromPage(string url)
{
var cars = new List<Car>();
// Открываем страницу в браузере
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<Car> 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");
}
}
}
}

13
Helpers/Strings.cs Normal file
View File

@ -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/";
}
}

483
MainForm.Designer.cs generated Normal file
View File

@ -0,0 +1,483 @@
namespace GtaVUsersInfo
{
partial class MainForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
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;
}
}

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using GtaVUsersInfo.Helpers;
namespace GtaVUsersInfo namespace GtaVUsersInfo
{ {
@ -21,5 +22,15 @@ namespace GtaVUsersInfo
{ {
} }
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");
}
}
} }
} }

15
packages.config Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.11.67" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Selenium.WebDriver" version="4.25.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net48" />
<package id="System.Text.Json" version="8.0.4" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>