Click Menu Automatically Using Web Scrapping In C#

In this article, We will learn how to open a browser and run a URL using Web Scraping.

What is Web Scrapping?

  • Web scraping is the technique of extracting data from a website using bots.
  • Web scrapers allow you to extract data from websites automatically, saving you or your coworkers time that would otherwise be spent on tedious data collection chores. It also means that you can collect data in far bigger quantities than a single human could.

Note:  This is only for learning purposes. We do not motivate you to breach the terms of any website. So please use it for legal purposes only.

  • Let us understand with help of an example.

First, create a console project and will install three NuGet packages which are required for Web Scrapping.

Selenium.Support

Selenium.WebDriver

Selenium.WebDriver.ChromeDriver

  • Then you have to add your current browser version of chromedriver.exe and add in your project folder, you can download it from here.
  • For example, my current chrome version is 99.0.4844.51


  • Then open the Program.cs file and add this code.
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;

namespace WebScrapping
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ChromeDriver driver = new ChromeDriver(@"D:\Parth Mandaliya\WenScrapping\WenScrapping\Driver"); // add your chromedriver.exe path here
                driver.Manage().Window.Maximize();
                driver.Navigate().GoToUrl("http://staging.thecodehubs.com/");
                driver.FindElement(By.Id("menu-item-13558")).Click();
            }
            catch (Exception ex)
            {
            }
        }
    }
}

Output

Hope you guys found something useful. Please give your valuable feedback and If you have any queries about this article then you can ask me in the comment section.

Also, check http://staging.thecodehubs.com/how-to-install-kioware-client-and-setup/

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories