Web Scraping using c# api method

coder rock 216 Reputation points
2023-05-11T15:05:42.29+00:00

I am trying to read other website data using asp.net c#.

Web login url: https://sts.defhc.com/account/login

after login need to redirect: https://www.defhc.com/hospitals/2868000 because after login this url i have some information that i need to read html.

I have tried below code but nothing output is coming for to read any html

            
            ```

for more information also i have posted into stack overflow but not got good answer

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,362 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,475 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
311 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. AgaveJoe 26,671 Reputation points
    2023-05-11T15:29:56.4166667+00:00

    Do a Google search for C# HTML parsers. The HTML Agility Pack has been around a long time and has code examples.

    https://html-agility-pack.net/


  2. Bruce (SqlWork.com) 59,036 Reputation points
    2023-05-11T15:36:43.8166667+00:00

    the login request is not correct. you need to reverse engineer the login. in the sample url, the username is passed in the url, the password in the form, and a anti-forgery field is required. you need to do a get of login. and read the session cookie, and parse out the validation token. then form (not json) post with the session cookie, and data in proper format.