Web Scraping using c# api method

coder rock 296 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,448 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,813 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.
326 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. AgaveJoe 28,026 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) 63,501 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.