cgreene
cgreene

Reputation: 59

C# Using HTTPClient to 'Navigate' a Website

So I am just beginning to learn C#, and one of my main goals is to be able to 'navigate' a website. I have done minimal research and have found that the two primary was to do this would be HTTPClient and Requests, and I would like to learn this through HTTPClient.

Now what I mean by navigate is to essentially bot a website for practice. This is like clicking buttons, putting text into fields, etc.

If anyone can give me an idea on where to start with this it would be much appreciated! Not looking for code specifically, just looking for what I should learn in HTTPClient to make this happen. Thanks!

Upvotes: 3

Views: 1426

Answers (2)

Gonzalo Bustamante
Gonzalo Bustamante

Reputation: 401

I think that you are a little confused about the concepts. HTTPClient send requests to some site, but you cannot click buttons or "navigate" inside the site.

If youre looking for a way to test some site, i recommend you learn about cypress.io. You can add text to your textboxes, click buttons or navigate in any site. All of this with a few lines of code with Javascript. Its free.

Otherwise, if you need to save values on a database depending of your "navigation", you have to research about scraping tools. I recommend you Selenium or any other scraping tool.

Usually HTTPClient is used when you have to consume a REST API.

Upvotes: 2

Jonas
Jonas

Reputation: 315

Basically you have to think about how a program could ‘see’ a website. You cannot expect to say to the HTTPClient: ‘Open page www.google.com and search for something.’ If you want to do this programmatically you have to exactly specify what your program should do.

For your purpose I recommend the HTML Agility Pack. This one can be used to get the navigation elements of a HTML document. This way you can parse a HTML delivered from a website into your program and do further stuff with it.

Kind regards :)

Upvotes: 1

Related Questions