> For the complete documentation index, see [llms.txt](https://dimitar-minchev.gitbook.io/developing-cross-platform-apps/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dimitar-minchev.gitbook.io/developing-cross-platform-apps/101_intorduction/109_applications/116_html_downloader_1.0.md).

# HTML Downloader 1.0

Използвайки интегрираната среда за разработка Visual Studio и езика за програмиране C# ще разработим универсално приложение за изтегляне HTML съдържанието на кода от Интернет страница.

{% hint style="info" %}
**Информация**

HTML е основният маркиращ език за описание и дизайн на уеб страници. HTML е стандарт в Интернет, а правилата се определят от международния консорциум W3C.

* Източник: [Wikipedia](https://en.wikipedia.org/wiki/HTML)
  {% endhint %}

## Start

1. Стартирайте интегрираната среда за разработка **Visual Studio**.
2. Създайте нов проект **Visual C# > Windows Universal > Blank App (Universal Windows)**.
3. За име на проекта запишете: **HTML Downloader 1.0**.

От менюто **Project** > **Manage NuGet Packages** потърсете и инсталирайте пакета **AngleSharp**, като е показано на фигурата:

![](/files/294noxVth3AMQT9S3UtD)

*Фиг. 40. Инсталация на допълнителен пакет към проекта*

Допълнителни пакети към проект можете да инсталитрате и алтернативно от менюто: **Tools > NuGet Package Manager > Package Manager Console**, като изпълните следната команда в конзолата:

```
PM> Install-Package AngleSharp -Version 0.16.1
```

## MainPage.xaml

Файлът **MainPage.xaml** съдържа изходния код от дизайна на потребителския интерфейс на разработваното приложение и се пише на езика XAML. Копирайте (Ctrl+C) и поставете (Ctrl+V) програмният фрагмент даден по-долу във Вашето приложение.

```xml
<!-- User Interface (UI): HTML Downloader 1.0 -->
<StackPanel Background="LightCoral" Padding="20">
        
        <!-- Title -->
        <TextBlock Text="HTML Downloader 1.0" FontSize="40" />

        <!-- URL -->
        <TextBlock Text="URL" FontSize="20" />
        <TextBox Name="URL" Text="http://www.minchev.eu" FontSize="20" />
        <Button Content="Download" Margin="0 10" Padding="20 10" FontSize="20" Click="Button_Click" />
        
        <!-- HTML -->
        <TextBox Name="HTML" Height="400" TextWrapping="Wrap" IsReadOnly="True" FontSize="20" />
    
</StackPanel>
```

Изглед от дизайна на потребителският интерфейс (XAML) в интегрираната среда за разработка Visual Studio по време на разработване на приложението:

![](/files/3JqLpYQ1b9h1AnmTzLdK)

*Фиг. 1.41. Изглед от дизайна на потребителският интерфейс*

## MainPage.xaml.cs

Файлът **MainPage.xaml.cs** съдържа изходния код от бизнес логиката на разработваното приложение и се пише на програмният език C#. Копирайте (Ctrl+C) и поставете (Ctrl+V) програмният фрагмент даден по-долу във Вашето приложение.

```csharp
// Business Logic (BL): HTML Downloader 1.0
public sealed partial class MainPage : Page
{
        // Constructor
        public MainPage()
        {
            this.InitializeComponent();
        }

        // Button Click Event Handler
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string html = await Download(new Uri(URL.Text));
            var temp = new HtmlParser().ParseDocument(html);
            string text = temp.Body.TextContent;
            HTML.Text = text;
        }

        // Download Handler
        private async Task<string> Download(Uri link)
        {
            HttpClient client = new HttpClient();
            return await client.GetStringAsync(link);
        }
}
```

## Demo

Изглед от бизнес логиката (C#) в интегрираната среда за разработка Visual Studio по време на разработване на приложението:

![](/files/qjMi6e2mZbyXa8QZOi7l)

*Фиг. 1.42. Изглед от бизнес логиката на разработваното приложение*

Стартирайте приложението от менюто: **Debug > Start Debugging** или като натиснете клавиш **F5**.

![](/files/IuemcWNIEOgyWcY81elx)

*Фиг. 1.43 Универслано приложение за изтегляне HTML съдържанието на кода от Интернет страница*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dimitar-minchev.gitbook.io/developing-cross-platform-apps/101_intorduction/109_applications/116_html_downloader_1.0.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
