<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arshia</title>
    <description>The latest articles on DEV Community by Arshia (@arshiya_arshiya_d3854900e).</description>
    <link>https://dev.to/arshiya_arshiya_d3854900e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1897978%2Fc3f415ad-ad22-4682-bc7a-c5e48eba829e.png</url>
      <title>DEV Community: Arshia</title>
      <link>https://dev.to/arshiya_arshiya_d3854900e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arshiya_arshiya_d3854900e"/>
    <language>en</language>
    <item>
      <title>Create GitHub profile viewer in web API c#</title>
      <dc:creator>Arshia</dc:creator>
      <pubDate>Fri, 09 Aug 2024 16:01:06 +0000</pubDate>
      <link>https://dev.to/arshiya_arshiya_d3854900e/create-github-profile-viewer-in-web-api-c-hmf</link>
      <guid>https://dev.to/arshiya_arshiya_d3854900e/create-github-profile-viewer-in-web-api-c-hmf</guid>
      <description>&lt;p&gt;Hi, my name is Arshia. In this article I'm gonna show your how to create a GitHub profile viewer in Web API c#.&lt;/p&gt;

&lt;p&gt;1- Open terminal, and write &lt;code&gt;dotnet new webapi --use-controllers&lt;/code&gt; (If you use .net cli on Windows, linux,mac), or if you use Visual Studio, Open Visual Studio then click on create new project and then select webapi project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzz6l7bcb3xsj88sajexm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzz6l7bcb3xsj88sajexm.png" alt="Image description" width="800" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2 - We need to create a class which named UserInfo. This class have below properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class UserInfo
{
    public string AdditionalName { get; set; }
    public string Name { get; set; }
    public string Bio { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, this image is shows How to Equal each property in a class to GitHub Profile&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4qsue8nvqlgccadtrwed.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4qsue8nvqlgccadtrwed.png" alt="Image description" width="600" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now , We add HtmlAgilityPack Package. you can use this command for add HtmlAgilityPack to your project. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;dotnet add package HtmlAgilityPack --version 1.11.62&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;HtmlAgilityPack is an HTML parser written in C# to read/write DOM and supports plain XPATH or XSLT. More information in &lt;a href="https://html-agility-pack.net/" rel="noopener noreferrer"&gt;Html Agility Pack&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All right, now just we create a controller with name GithubController&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dotnet new apicontroller -n GithubController&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In visual studio, right click on your project and then click on Add, afterward click on class.&lt;/p&gt;

&lt;p&gt;In inside GithubController, Add this methods and variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    [Route("api/[controller]")]
    [ApiController]
    public class GithubController : ControllerBase
    {
        private HttpClient? _httpClient;
        private Uri? _uri;
        private HtmlDocument? _htmlDoc;


        [HttpGet("Profile/{name}")]
        public async Task&amp;lt;ActionResult&amp;lt;string&amp;gt;&amp;gt; GetProfile(string name)
        {
            var pageResult = await LoadPage(name);
            if (pageResult)
            {
                var iamgenode =  _htmlDoc?.DocumentNode.SelectNodes("//img")[2].Attributes["src"];
                var image = iamgenode?.Value;

                return Ok(image);
            }

            return NotFound("User not found in github.");
        }


        private async Task&amp;lt;bool&amp;gt; LoadPage(string name)
        {
            var uri = "https://github.com/" + name;

            _uri = new Uri(uri);

            _httpClient = new HttpClient();
            _httpClient.BaseAddress = _uri;

            var webPage = new HtmlWeb();
            _htmlDoc = webPage.Load(_httpClient.BaseAddress);
            var pageFounder = _htmlDoc.DocumentNode.SelectSingleNode("//title");

            if (pageFounder.InnerHtml == "Page not found · GitHub · GitHub")
                return false;

            return true;
        }



    }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we run project.Open your browser and append the following address to the url.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/api/github/profile/Arshiya-A&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbciszx9d6eegorjcph1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbciszx9d6eegorjcph1.png" alt="Image description" width="569" height="132"&gt;&lt;/a&gt;&lt;br&gt;
As you see, the profile image is shows.Just sufficient, received url copy and paste in browser url.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgn3d6p0theebf3aryga.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgn3d6p0theebf3aryga.png" alt="Image description" width="542" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For testing APIs, you can use swagger api in your project.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now add this method to GithubController.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   [HttpGet("Info/{name}")]
        public async Task&amp;lt;ActionResult&amp;lt;UserInfo&amp;gt;&amp;gt; GetInfo(string name)
        {

            var pageResult = await LoadPage(name);
            if (pageResult)
            {
                var additionalNameSpan = _htmlDoc.DocumentNode.SelectNodes("//span")[37];
                var nameSpan = _htmlDoc.DocumentNode.SelectNodes("//span")[36];

                var bioDiv_Type1 = _htmlDoc.DocumentNode.SelectNodes("//div")[138];
                var bioDiv_Type2 = _htmlDoc.DocumentNode.SelectNodes("//div")[146];

                string additionalName = GetAdditonalName(additionalNameSpan);

                string username = GetUsername(nameSpan);

                string bio = "User is not have bio";
                bio = GetBio(bioDiv_Type1, bioDiv_Type2);

                var userInfo = new UserInfo()
                {
                    AdditionalName = additionalName,
                    Name = username,
                    Bio = bio,
                };

                return Ok(userInfo);
            }

            return NotFound("User not found in github.");
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And run again project.Result is following image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhto8vb586i7gwsomx02n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhto8vb586i7gwsomx02n.png" alt="Image description" width="800" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;bioDiv_Type 2 for some profiles , that have follower and following.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thank you for reading this article. You can see this project and my other projects on GitHub.&lt;br&gt;
This project address : &lt;a href="https://github.com/Arshiya-A/My-private-room/releases/tag/Api-Webapi-ProfileViewer-github-githubprofileviewer" rel="noopener noreferrer"&gt;Github profile viewer&lt;/a&gt;&lt;br&gt;
My GitHub address : &lt;a href="https://github.com/Arshiya-A" rel="noopener noreferrer"&gt;My GitHub page&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Web music player with html-css-javascript</title>
      <dc:creator>Arshia</dc:creator>
      <pubDate>Wed, 07 Aug 2024 19:12:46 +0000</pubDate>
      <link>https://dev.to/arshiya_arshiya_d3854900e/web-music-player-with-html-css-javascript-3hc</link>
      <guid>https://dev.to/arshiya_arshiya_d3854900e/web-music-player-with-html-css-javascript-3hc</guid>
      <description>&lt;p&gt;Hi, my name is Arshia and this is my first post on I dev.to . I made a simple web music player with HTML, css and javascript. you can add this widget to your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74p7gf4jodwcsc63qrhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74p7gf4jodwcsc63qrhu.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Soon , in dev.to im create a post related by how to use this music player and how to worked that but before that you can see this post on my github channel&lt;/p&gt;

&lt;p&gt;GitHub : &lt;a href="https://github.com/Arshiya-A" rel="noopener noreferrer"&gt;https://github.com/Arshiya-A&lt;/a&gt;&lt;/p&gt;

</description>
      <category>widget</category>
      <category>musicplayer</category>
      <category>javascript</category>
      <category>htmlcss</category>
    </item>
  </channel>
</rss>
