This article was published as a part of the Data Science Blogathon.
“In this rushing world, Don’t Do hard work, it’s better to do Work Smartly.
This line fits perfectly in the world of technology where you have to act differently to get the results better & faster.”
Collection of data from the web is termed as Web Scraping, Web Data Extraction & Web Harvesting. These days everything & everyone needs fuel to run. Data is the most precious fuel to run any organization. Finding the data is good; extracting it even better; doing it using automation is perfect.
Cypress is an advanced & next-generation front end testing tool built for the modern web.
Cypress is a free, open-source, locally installed Test Runner and a Dashboard Service for recording your tests. It aims to restrict the hurdles that the engineers and developers face while testing web applications based on React and Angular JS.
It is most often compared to Selenium; however, Cypress is different fundamentally and architecturally.
Performed on Versions
Let’s perform web scraping using Cypress. Just check the website for the data you want to scrape and get the list of parent and child HTML tags.
I select this website “https://www.bullion-rates.com/gold/INR/2007-1-history.htm” and want to scrape data of gold rates along with dates.
Create a Java Script file & open it into Microsoft Visual Studio, where we start to code for Web scraping.
Java Script code looks like this to pass the URL.
When you know the HTML tags, it’s quite easy to find them in which your data is present. To see the HTML tags; right-click and select the inspect option.
If you noticed table id is “dtDGrid” and table body is “tbody” under that table row tag “tr” in which our data resides in the “DataRow” tag.
Now, if you want to frame the selector it would be like this
In selector framing there is “#” which represents Id & “.” represents the class.
If you look closely all the data are present under table data tag “td” under “DataRow”. So now, I have to iterate through “td” HTML tag to get all the data within it.
Our code will be like this after including the HTML Tags:-
Code be like this to print the data:-
In this way, you can cover more child HTML tags to scrape data.
I tried to explain Web Scraping using Cypress in a very simple way. Hope this will help you.
If you have any questions about the code or web scraping in general, reach out to me on
We will meet again with something new.
Till then,
Happy Coding..!