<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Garima</title>
    <description>The latest articles on DEV Community by Garima (@garimasharma).</description>
    <link>https://dev.to/garimasharma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F536964%2F63566e23-9898-45d1-8bca-65ec646a901f.jpg</url>
      <title>DEV Community: Garima</title>
      <link>https://dev.to/garimasharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/garimasharma"/>
    <language>en</language>
    <item>
      <title>Step-by-Step guide to set up Node server with TypeScript</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Tue, 29 Oct 2024 03:44:30 +0000</pubDate>
      <link>https://dev.to/garimasharma/step-by-step-guide-to-setup-node-server-with-typescript-fd</link>
      <guid>https://dev.to/garimasharma/step-by-step-guide-to-setup-node-server-with-typescript-fd</guid>
      <description>&lt;p&gt;So, I’m pretty new to TypeScript. As someone who’s been working with Node.js and JavaScript for a while, I thought switching to TypeScript would be a breeze. You know, it's just JavaScript with types slapped on, right? Well, I quickly realized it’s not that simple.&lt;/p&gt;

&lt;p&gt;I wanted to find a good guide or video that explained how to build a Node.js server with TypeScript from scratch—something that didn’t feel like a puzzle missing half the pieces. But honestly, most of the stuff out there either skimmed over the basics or assumed I was already some TypeScript expert. It was frustrating!&lt;/p&gt;

&lt;p&gt;That’s when I thought, why not write down everything I’ve learned so far? If you’re a JavaScript or Node.js developer like me, and you’re struggling to find a decent step-by-step on how to get started with TypeScript, I’ve got you covered. Let’s make this transition as smooth as possible, without the head-scratching moments.&lt;/p&gt;

&lt;p&gt;Alright, let’s dive in! We will set up a Node.js server with TypeScript, and we will look at some other cool tricks along the way. &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Initialize Your Node Project
&lt;/h2&gt;

&lt;p&gt;First things first, we need to initialize a Node.js project. Open up your terminal, go to your project folder, and run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-y&lt;/code&gt; flag just skips all the annoying setup questions like package name, version, etc. It says "yes" to everything, and bam! You’ve got yourself a &lt;code&gt;package.json&lt;/code&gt; file. This is where Node.js tracks all the dependencies and scripts for your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create Your First File
&lt;/h2&gt;

&lt;p&gt;Next up, create a file named &lt;code&gt;index.js&lt;/code&gt;. For now, we’ll work in plain JavaScript to see how things work before we switch to TypeScript.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;index.js&lt;/code&gt;, let’s try importing a package. The traditional way of doing this in Node.js is by using CommonJS syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we are using the built-in file system module, a common pattern in Node.js. If you’ve worked with JavaScript before, this should be familiar. However, most developers today prefer using the import-export syntax as it looks cleaner, more organized, and fancy. &lt;/p&gt;

&lt;p&gt;Now if we convert this to the new syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now of we try to run this code we might be getting some errors stating some warning saying we cannot use this ES module unless we update our package.json and change the type to module&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0kxzag50q5bner38hlk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0kxzag50q5bner38hlk.png" alt=" " width="800" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Simply add &lt;code&gt;type: 'module'&lt;/code&gt; in the &lt;code&gt;package.json&lt;/code&gt; file. This tells Node to use Es module instead of require. And now our code might be working fine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;module&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's talk about Typescript because this is what this blog is all about. Go ahead and install &lt;code&gt;typescript&lt;/code&gt; as a dev dependency because we don't need it in the production environment. You can use any package manager you want to use for installing the packages whether it be &lt;code&gt;pnpm&lt;/code&gt;, &lt;code&gt;bun&lt;/code&gt;, &lt;code&gt;npm&lt;/code&gt; or whatever.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i typescript &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah, we have installed it but what exactly is typescript?&lt;/p&gt;

&lt;p&gt;TypeScript is a superset of JavaScript, meaning it is built on top of JavaScript by adding optional static typing. This means you can define the types of variables, functions, and objects, helping to catch errors early in the development process. &lt;/p&gt;

&lt;p&gt;Now this is important! TypeScript code needs to be compiled into regular JavaScript so that it can run in browsers or Node.js environments, as they don't natively understand TypeScript. And now we know why we don't need it in the production environment. &lt;/p&gt;

&lt;p&gt;To convert the Typescript code to Javascript, we need to add a script in out &lt;code&gt;package.json&lt;/code&gt; that will run the Typescript compiler that converts the TS code to the JS or technically speaking building the application. Go to the &lt;code&gt;package.json&lt;/code&gt; and inside the scripts object add a build command that helps us to do the covering thing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;scripts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
&lt;span class="nl"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tsc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="c1"&gt;// ... rest of the commands&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Typescript needs some configurations to get started with it. Before actually starting the configuration let's organise out root directory. Create a &lt;code&gt;src&lt;/code&gt; folder and drag the &lt;code&gt;index.js&lt;/code&gt; file we just created and change the extension to &lt;code&gt;.ts&lt;/code&gt; now we have an &lt;code&gt;index.ts&lt;/code&gt; file inside the &lt;code&gt;src&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;When using node built-in modules you might get an error that says it cannot find corresponding type declarations. In lay man, it says install the types for node. Install the types for node using this command and the error should disappear.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i @types/node &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;tsc --init&lt;/code&gt;, you might be able to see a &lt;code&gt;tsconfig.json&lt;/code&gt; file if not go ahead and create it, we don't have to worry about it. We will now configure typescript to make it behave like we want it to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;compilerOptions&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;target&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;es2020&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;module&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;NodeNext&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rootDir&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Update this to your source directory&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;outDir&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./dist&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;// Update this to your desired output directory&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;include&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// Ensure this matches your source directory&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;exclude&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node_modules&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dist&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// Exclude output and dependency directories&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can copy-paste the configurations above or create your own to, but trust me this config works for almost all of the TS projects. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;target&lt;/code&gt;: Specifies the JavaScript version that TypeScript should compile to. "es2020" here means the compiled code will use ECMAScript 2020 features.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;module&lt;/code&gt;: Determines the module code generation method. "NodeNext" is suited for modern Node.js environments that use ES Modules (import/export syntax) rather than CommonJS.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rootDir&lt;/code&gt;: Specifies the directory where your source code files are located. "./" means the root directory, but you can change it to your specific source folder.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;outDir&lt;/code&gt;: Defines where the compiled JavaScript files will be output. "./dist" sets this to the dist folder, so all compiled files go there.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;include&lt;/code&gt;: Specifies which files and folders to include in the compilation. "./" includes all files in the root directory. Adjust it if your source files are in a different folder.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;exclude&lt;/code&gt;: Excludes certain directories from compilation, typically those you don’t want TypeScript to process. Here, "node_modules" (dependencies) and "dist" (output folder) are excluded to avoid redundant checks.&lt;/p&gt;

&lt;p&gt;Go into the terminal and run the build command we just wrote in package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you might be able to a &lt;code&gt;dist&lt;/code&gt; folder in your root directory containing an &lt;code&gt;index.js&lt;/code&gt; file. This command generates the dist folder that contains the Javascript code that we can actually run on NodeJs. &lt;/p&gt;

&lt;p&gt;Voila! We are done with setting up typescript for creating our Nodejs server using Typescript. There are tons of other options to configure the tsconfig but I don't think we would need to use them. &lt;/p&gt;

&lt;h2&gt;
  
  
  Set up a Node Server
&lt;/h2&gt;

&lt;p&gt;Creating a Node server will work the same as we do it while working with Javascript. We just need to install types for our dependencies eg. express node module. We need the express module in production environment and types are needed only the development environment.&lt;/p&gt;

&lt;p&gt;Install dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i express&lt;span class="p"&gt;;&lt;/span&gt;
npm i ts-node @types/express &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic Server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express, { urlencoded, json } from "express";

const app = express();

app.use(urlencoded({ extended: true }));
app.use(json());

app.listen(4000, () =&amp;gt; {
  console.log(`Server is listening at port 4000`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're done with setting up a Node server. Run &lt;code&gt;npm run dev&lt;/code&gt;, your server might be up and running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Now the question is do we need Typescript?
&lt;/h2&gt;

&lt;p&gt;Whether or not, it totally depends on one's project's needs. But, I believe using Typescript makes Javascript somewhat strict. It provides type-checking and various other features. As Javascript is a dynamically typed language, it can do blunders sometimes, you may never know what is leading to the server crash. Where you might be accidentally updating a string var with an integer. Javascript is sweet it will allow you to do that, but Typescript no,no sweetheart!&lt;/p&gt;

&lt;p&gt;In the end, it's all Javascript :)&lt;/p&gt;

&lt;h3&gt;
  
  
  Want to connect?
&lt;/h3&gt;

&lt;p&gt;
  
    &lt;a href="https://twitter.com/garimaasharma_" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; ·
    &lt;a href="https://dev.to/garimasharma"&gt;blogs&lt;/a&gt; ·
    &lt;a href="https://garimasharma.netlify.app" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt; ·
    &lt;a href="mailto:sharmagarima814@gmail.com"&gt;email&lt;/a&gt; ·
    &lt;a href="https://www.linkedin.com/in/garimaasharma/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;Written and edited by &lt;a href="https://twitter.com/garimavatss" rel="noopener noreferrer"&gt;me&lt;/a&gt;❤️ &lt;/p&gt;

</description>
      <category>typescript</category>
      <category>beginners</category>
      <category>node</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Unlock the Power of Web Scraping with Proxies and ScrapeOps Monitoring</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Tue, 10 Sep 2024 05:27:49 +0000</pubDate>
      <link>https://dev.to/garimasharma/unlock-the-power-of-web-scraping-with-proxies-and-scrapeops-monitoring-1n3p</link>
      <guid>https://dev.to/garimasharma/unlock-the-power-of-web-scraping-with-proxies-and-scrapeops-monitoring-1n3p</guid>
      <description>&lt;p&gt;In today's fast-paced digital world, businesses, marketers, and developers rely on web scraping to gather crucial data from various websites. But have you ever wondered what keeps your web scraper running smoothly without getting blocked? That’s where proxies come in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Proxy?
&lt;/h2&gt;

&lt;p&gt;A proxy acts like a middleman between your computer (or scraper) and the website you're trying to gather data from. Instead of directly connecting your scraper to the target website, the proxy sends the request on your behalf, using its own IP address. Think of it like having a different digital identity each time you visit a website.&lt;/p&gt;

&lt;p&gt;When web scraping, sending too many requests from the same IP can trigger the target site's security and lead to blocks or rate limits. By using proxies, your scraper can spread out the requests across multiple IP addresses, avoiding detection and ensuring smoother operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do Proxies Work?
&lt;/h2&gt;

&lt;p&gt;Here’s a simple breakdown of how proxies work during web scraping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your scraper sends a request to a proxy server instead of the website directly.&lt;/li&gt;
&lt;li&gt;The proxy server forwards the request to the target website.&lt;/li&gt;
&lt;li&gt;The website sees the proxy’s IP address, not yours.&lt;/li&gt;
&lt;li&gt;The proxy returns the data from the website to your scraper.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're new to web scraping, you might not realize the importance of proxies. Websites often restrict access when they detect too many requests coming from the same IP address. A proxy serves as a middleman, helping you send requests from different IP addresses, avoiding detection and ensuring uninterrupted access to your target sites.&lt;/p&gt;

&lt;p&gt;But proxies alone aren't enough. You also need to monitor your scraper's performance and manage your scraping infrastructure to ensure it runs smoothly without errors or inefficiencies. This is where ScrapeOps' complete web scraping toolkit comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Three Products from ScrapeOps You Need to Know
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ScrapeOps Monitoring
&lt;/h3&gt;

&lt;p&gt;ScrapeOps Monitoring is a must-have tool for anyone serious about web scraping. It provides a clear overview of your scraper’s performance and helps you spot any issues that might be hindering your data collection process.&lt;/p&gt;

&lt;p&gt;With a 30-second SDK installation, ScrapeOps Monitoring automatically tracks and visualizes key metrics like:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Job Progress Stats&lt;/em&gt;: Track the number of pages scraped, items parsed, and errors encountered.&lt;br&gt;
Response Times &amp;amp; Success Rates: Understand how efficiently your scraper is performing.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Error &amp;amp; Warning Tracking&lt;/em&gt;: Spot issues early and fix them before they escalate.&lt;br&gt;
The ScrapeOps dashboard makes it easy to compare the performance of your scraping jobs against historical data, giving you the insights you need to optimize your scraping processes continuously.&lt;/p&gt;

&lt;p&gt;Health Checks &amp;amp; Alerts are another crucial feature, ensuring you’re always notified about potential issues. Whether you prefer alerts via Slack or want to generate daily reports, ScrapeOps has you covered.&lt;/p&gt;
&lt;h3&gt;
  
  
  ScrapeOps Server Manager &amp;amp; Scheduler
&lt;/h3&gt;

&lt;p&gt;Managing and scheduling scrapers can be time-consuming, especially if you're working with multiple servers. ScrapeOps Server Manager &amp;amp; Scheduler makes this process effortless. It allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy your scrapers to multiple servers easily.&lt;/li&gt;
&lt;li&gt;Schedule scraping jobs, ensuring they run at specific times without manual intervention.&lt;/li&gt;
&lt;li&gt;Monitor performance directly from the ScrapeOps dashboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With support for integration via SSH and Scrapyd, ScrapeOps makes it easy for you to control your web scraping infrastructure from one centralized location.&lt;/p&gt;
&lt;h3&gt;
  
  
  ScrapeOps Proxy Aggregator
&lt;/h3&gt;

&lt;p&gt;Finding and managing proxies can be a daunting task. Enter ScrapeOps Proxy Aggregator. This tool allows you to access the best-performing proxies from a single endpoint. ScrapeOps takes care of testing and selecting the most reliable proxies, so you can focus on what matters most—extracting data.&lt;/p&gt;

&lt;p&gt;The Proxy Aggregator simplifies your scraping setup by aggregating the best proxy options, making it a reliable choice whether you’re scraping hundreds or thousands of websites. No more hunting for proxies or worrying about failures.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why ScrapeOps is a Game-Changer for Web Scraping
&lt;/h2&gt;

&lt;p&gt;By using the full suite of ScrapeOps tools, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maximize scraper performance with real-time monitoring and detailed analytics.&lt;/li&gt;
&lt;li&gt;Optimize your infrastructure with easy-to-manage server scheduling.&lt;/li&gt;
&lt;li&gt;Eliminate proxy headaches with their reliable Proxy Aggregator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plus, getting started with ScrapeOps is quick and easy. You can set up ScrapeOps Monitoring in just 30 seconds, and all their products seamlessly integrate into your existing scraping framework.&lt;/p&gt;
&lt;h2&gt;
  
  
  Get Started with ScrapeOps and Save!
&lt;/h2&gt;

&lt;p&gt;Ready to improve your web scraping? You can sign up for ScrapeOps today using this link and save 10% with coupon code &lt;strong&gt;SCRPGS10&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Whether you're an experienced developer or just getting started with web scraping, ScrapeOps offers everything you need to run efficient, error-free scraping projects.&lt;/p&gt;
&lt;h3&gt;
  
  
  Want to make your web scraper?
&lt;/h3&gt;

&lt;p&gt;Checkout the &lt;a href="https://dev.to/garimasharma/the-ultimate-guide-to-web-scraping-with-node-js-bn3"&gt;The Ultimate Guide to Web Scraping with Node.js&lt;/a&gt; Or directly get the code &lt;a href="https://github.com/Garima-sharma814/Web-Scraper" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Connect?
&lt;/h2&gt;

&lt;p&gt;
  
    &lt;a href="https://twitter.com/garimaasharma_" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; ·
    &lt;a href="https://dev.to/garimasharma"&gt;blogs&lt;/a&gt; ·
    &lt;a href="https://garimasharma.netlify.app" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt; ·
    &lt;a href="mailto:sharmagarima814@gmail.com"&gt;email&lt;/a&gt; ·
    &lt;a href="https://www.linkedin.com/in/garima-sharma08/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webscraping</category>
      <category>proxymanagement</category>
      <category>webscraper</category>
      <category>webscrapingools</category>
    </item>
    <item>
      <title>Working in a startup as a Software Developer</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Mon, 04 Dec 2023 08:03:11 +0000</pubDate>
      <link>https://dev.to/garimasharma/working-in-a-startup-as-a-software-developer-f85</link>
      <guid>https://dev.to/garimasharma/working-in-a-startup-as-a-software-developer-f85</guid>
      <description>&lt;p&gt;It's been a while since I wrote a blog. I usually cover topics related to the things I know in tech. I should share my developer's journey in a startup this time. &lt;/p&gt;

&lt;h4&gt;
  
  
  TL;DR
&lt;/h4&gt;

&lt;p&gt;This blog contains my journey in a startup company. Everything I share here is entirely my beliefs and thoughts. I've been working as a software developer in a startup &lt;a href="https://idreameducation.org/" rel="noopener noreferrer"&gt;iDream Education&lt;/a&gt; for 2 years now. Therefore, I am sharing my insights, and my thoughts on working as a dev in this company. I hope it helps you decide whether working in a startup is something you'd consider and provides a glimpse into the workings of early-stage startups.&lt;/p&gt;

&lt;h3&gt;
  
  
  Earlier in 2021 ...
&lt;/h3&gt;

&lt;p&gt;From the start, I believed working in startups was a great way to learn about new things, so I decided to start my career and join a startup where I could take full responsibility for building something meaningful in a product that adds value to people's lives. &lt;/p&gt;

&lt;p&gt;Honestly, as a fresher one should be thankful to the organization that saw his/her potential without actually seeing their past experiences and gave them a chance to kick start their career. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://idreameducation.org/" rel="noopener noreferrer"&gt;iDream Education&lt;/a&gt; is where I started my corporate journey, as a Web Developer and shipped my first line of code in a real-time project. Working at iDream Education is a fantastic experience with amazing community support, providing opportunities to learn something new almost every single day. &lt;/p&gt;

&lt;p&gt;In the initial time of mine, I faced a lot of hindrances in my journey like not knowing what and how to do a task. But, this is the phase where one can learn and shape their life. Working in a startup is like gambling, either you fly so high or you fall fast, but you shouldn't forget you can retry anytime.&lt;/p&gt;

&lt;p&gt;Be water, my friend! - Bruce Lee. Water can take the shape of the container it is stored in. A startup will help you shape yourself and help you to cope with multiple situations at a time. &lt;/p&gt;

&lt;h3&gt;
  
  
  Work Pressures ...
&lt;/h3&gt;

&lt;p&gt;Do not, do not, and do not avoid work pressures. While I understand, that being accountable for your product might frustrating sometimes but will teach you a lot, like, smart work is better than hard work. This is one of the healthy pressures one should deal with in their life. If you avoid work pressure you might lack the ability to manage and organize yourself.  &lt;/p&gt;

&lt;p&gt;When you work on a product alone you can learn multiple things at a time i.e.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multitasking;&lt;/li&gt;
&lt;li&gt;handling pressures;&lt;/li&gt;
&lt;li&gt;brainstorming;&lt;/li&gt;
&lt;li&gt;inter and Intra Teamwork;&lt;/li&gt;
&lt;li&gt;understanding human behaviors;&lt;/li&gt;
&lt;li&gt;time management;&lt;/li&gt;
&lt;li&gt;leadership skills;&lt;/li&gt;
&lt;li&gt;consistency;&lt;/li&gt;
&lt;li&gt;and many more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Later in 2023 ...
&lt;/h3&gt;

&lt;p&gt;Still working in the same organization as a Senior Full-Stack Web Developer with better team management skills, better time management skills, higher technical knowledge as compared to myself back in 2021, and many more that I am unaware of. &lt;/p&gt;

&lt;p&gt;One can decide to change organizations as per their understanding. I chose to stay committed to this org because  I feel it is my responsibility to serve something good to this organization, in return for the skills I've developed. &lt;/p&gt;

&lt;h3&gt;
  
  
  Ending quotes ...
&lt;/h3&gt;

&lt;p&gt;If you're a fresher and want to learn new things and experience a thrilling life, you should kick start your journey in a startup and see where your life goes. &lt;/p&gt;

&lt;p&gt;Thanks for Reading :)&lt;/p&gt;

&lt;h4&gt;
  
  
  Want to connect?
&lt;/h4&gt;

&lt;p&gt;
  
    &lt;a href="https://twitter.com/garimaasharma_" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; ·
    &lt;a href="https://dev.to/garimasharma"&gt;blogs&lt;/a&gt; ·
    &lt;a href="https://garimasharma.netlify.app" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt; ·
    &lt;a href="mailto:sharmagarima814@gmail.com"&gt;email&lt;/a&gt; ·
    &lt;a href="https://www.linkedin.com/in/garimaasharma/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>startup</category>
      <category>career</category>
    </item>
    <item>
      <title>Integrated Terminal - A powerful feature!</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Thu, 09 Feb 2023 03:49:26 +0000</pubDate>
      <link>https://dev.to/garimasharma/integrated-terminal-a-powerful-feature-5bna</link>
      <guid>https://dev.to/garimasharma/integrated-terminal-a-powerful-feature-5bna</guid>
      <description>&lt;p&gt;VS Code provides a full fledged terminal that starts at the root of the workspace.&lt;/p&gt;

&lt;p&gt;To open the terminal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the ⌃` keyboard shortcut to toggle the terminal panel.&lt;/li&gt;
&lt;li&gt;Use the ⌃⇧` keyboard shortcut to create a new terminal.&lt;/li&gt;
&lt;li&gt;Use the View &amp;gt; Terminal or Terminal &amp;gt; New Terminal menu commands.&lt;/li&gt;
&lt;li&gt;From the Command Palette (⇧⌘P), use the View: Toggle Terminal command.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funce4d6elw622tf9sl2k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funce4d6elw622tf9sl2k.png" alt="Terminal Image" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can open a new terminal session directly in VS Code in your working directory using &lt;code&gt;ctrl+ backtick&lt;/code&gt; (the key below the escape key).&lt;/p&gt;

&lt;p&gt;When you start your terminal it uses your default shell, if you click on the caret it will show you a list of shells you can use if needed. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwya90h46i0w0t3xy45k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftwya90h46i0w0t3xy45k.png" alt="Shells" width="582" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What often happens though is you may need multiple terminal sessions running at the same time. Like one for your server and other for managing git or tests.&lt;/p&gt;

&lt;p&gt;You can also change the name, color, icon of that terminal session, right click on the terminal session you want to change the information for you may see these options &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvavnbov1iml1daz70ank.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvavnbov1iml1daz70ank.png" alt="terminal sessions" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on change color, different color options may appear in the command palatte.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bd1t43if6gealimsb8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bd1t43if6gealimsb8t.png" alt="terminal info" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d07sjtlnr2pn2u2m8ng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d07sjtlnr2pn2u2m8ng.png" alt="terminal info" width="466" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly you can change the icon, name, color etc. And now you need to fumble between the different terminals to figure out what each one is doing. &lt;/p&gt;

&lt;p&gt;Now if you type out an actual command in the terminal and you screw it up you can actually you can use control + arrows(right|left) to navigate through the command your mouse won't even work here. You can clear the terminal using &lt;code&gt;ctrl|cmd + k&lt;/code&gt; then use up arrow to go to the last command in your history. &lt;/p&gt;

&lt;h2&gt;
  
  
  Tasks
&lt;/h2&gt;

&lt;p&gt;What if there is a way where you don't have to write the same command over and over again in the same terminal. Like how many time you might have written &lt;code&gt;npm start&lt;/code&gt; or &lt;code&gt;npm run dev&lt;/code&gt; to simplify thing you can create a VS Code task which is just a JSON configuration that contains the commands that you want to run in the terminal. &lt;/p&gt;

&lt;h3&gt;
  
  
  Create a task
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to command palette &lt;code&gt;ctrl|cmd + shift + p&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;write task &lt;/li&gt;
&lt;li&gt;select configure default build task&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6kjt1gvnkd84vn9ad4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6kjt1gvnkd84vn9ad4o.png" alt="vs code tasks" width="800" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjjwnc7wpcasifskrvicl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjjwnc7wpcasifskrvicl.png" alt="vs code tasks" width="800" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflwv7913cxe3yk6hfde2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflwv7913cxe3yk6hfde2.png" alt="vs code tasks" width="800" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2b9f2u86yh62mllif112.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2b9f2u86yh62mllif112.png" alt="vs Code tasks" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All these powerful features may help you boost your productivity while coding. Let me know in the comments below the productivity hack you use to boost your productivity. &lt;/p&gt;

&lt;h4&gt;
  
  
  Want to connect?
&lt;/h4&gt;

&lt;p&gt;
  
    &lt;a href="https://twitter.com/garimaasharma_" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; ·
    &lt;a href="https://dev.to/garimasharma"&gt;blogs&lt;/a&gt; ·
    &lt;a href="https://garimasharma.netlify.app" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt; ·
    &lt;a href="mailto:sharmagarima814@gmail.com"&gt;email&lt;/a&gt; ·
    &lt;a href="https://www.linkedin.com/in/garima-sharma08/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>VS Code - Amateur to Pro 2</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Sun, 22 Jan 2023 11:08:31 +0000</pubDate>
      <link>https://dev.to/garimasharma/vs-code-amateur-to-pro-2-175e</link>
      <guid>https://dev.to/garimasharma/vs-code-amateur-to-pro-2-175e</guid>
      <description>&lt;p&gt;VS Code Productivity tips and speed hacks - 2&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Move around quickly &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Command palette is awesome but it doesn't help you write your code faster, when you see a line of code you want to edit the natural approach is to select and highlight that line. A developer might do this 100s/1000s of times a day.&lt;/p&gt;

&lt;p&gt;A faster way to get to where you want to edit is to hit &lt;code&gt;ctrl + go&lt;/code&gt; followed by the line number you want to edit, from there use the arrow keys to move character by character and start editing. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frcvdold911o9vccmxth2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frcvdold911o9vccmxth2.png" alt="cmd+g" width="800" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multi-line editing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to edit a word in multiple lines at the same time when the cursor lands on the word you want to edit with the help of the above-mentioned method hit &lt;code&gt;ctrl + d&lt;/code&gt; or &lt;code&gt;cmd + d&lt;/code&gt; again and again to select the same word. And now you're a 3x developer editing multiple lines of code at the same time.&lt;/p&gt;

&lt;p&gt;In some cases you may want to use the mouse to select multi-line editing in such cases hold the &lt;code&gt;alt&lt;/code&gt; or &lt;code&gt;option&lt;/code&gt; key and click on different parts of the code in different lines where you want to edit, the editor will then set cursors in multiple places which will be then useful and easy to use for writing repetitive codes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tu9mmuokkp2mvdm2fi1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4tu9mmuokkp2mvdm2fi1.png" alt="Multi line editing" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl05dzwwz75orxjex7i28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl05dzwwz75orxjex7i28.png" alt="Multi line editing" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Delete or move a line &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to delete a line from VS Code and paste it somewhere else the amateur approach is to highlight and select the line hit &lt;code&gt;ctrl+x&lt;/code&gt; or &lt;code&gt;cmd+x&lt;/code&gt; to cut the line and paste it with &lt;code&gt;ctrl+v&lt;/code&gt; or &lt;code&gt;cmd+v&lt;/code&gt; where you want to paste it. &lt;/p&gt;

&lt;p&gt;But a better approach to do that is if you already have your cursor on the line you want to cut hit &lt;code&gt;ctrl+x&lt;/code&gt; or &lt;code&gt;cmd+x&lt;/code&gt; to cut the line not highlighting it required. Or if you want to paste that line above or below you can simply move the line with &lt;code&gt;option/alt + up arrow/down arrow&lt;/code&gt;. Or if want to copy the line down by hitting the command available in your VS Code keyboard shortcuts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Custom snippets&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In many projects, you may find yourself writing the same boilerplate again and again if you find yourself doing that a faster way to increase your productivity is to add a custom snippet. &lt;/p&gt;

&lt;p&gt;From the command palette run the &lt;code&gt;configure user snippet&lt;/code&gt; command. You can create global projects to use them across all over your project, now you edit this &lt;code&gt;JSON&lt;/code&gt; file to add your snippets. &lt;/p&gt;

&lt;p&gt;And now in your file, you can use the &lt;code&gt;insert snippet command&lt;/code&gt; to insert your snippet. But if you work with a popular framework there are chances someone might have done that already for you. Before you build yours go into the extensions section and check out for your language snippets if available. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzg4v8gh7njxxrdmnzo3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzg4v8gh7njxxrdmnzo3.png" alt="command palette" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzae7nmid4fwqv04cyew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzae7nmid4fwqv04cyew.png" alt="command palette" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkczx9rxdp1t56v8da4kw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkczx9rxdp1t56v8da4kw.png" alt="Snippet" width="800" height="757"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Auto-create directory/file&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you need to create a file in a folder that doesn't exist yet you can create that file by clicking on the create new file button, writing the file name with the nested directory names on top of it by putting a slash in front on them to separate them and VS Code will automatically create those directories.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkfxxooako4hy9fqrllf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkfxxooako4hy9fqrllf.png" alt="Auto create directory/file" width="520" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5e7abg8l9wl5bliz9o6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5e7abg8l9wl5bliz9o6.png" alt="Auto create directory/file" width="502" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me know in the comments below the productivity hack you use to boost your productivity. &lt;/p&gt;

&lt;h5&gt;
  
  
  Want to connect?
&lt;/h5&gt;

&lt;p&gt;
  
    &lt;a href="https://twitter.com/garimaasharma_" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; ·
    &lt;a href="https://dev.to/garimasharma"&gt;blogs&lt;/a&gt; ·
    &lt;a href="https://garimasharma.netlify.app" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt; ·
    &lt;a href="mailto:sharmagarima814@gmail.com"&gt;email&lt;/a&gt; ·
    &lt;a href="https://www.linkedin.com/in/garima-sharma08/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>productivity</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>VS Code - Amateur to Pro</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Thu, 29 Dec 2022 04:25:26 +0000</pubDate>
      <link>https://dev.to/garimasharma/vs-code-amateur-to-pro-43n0</link>
      <guid>https://dev.to/garimasharma/vs-code-amateur-to-pro-43n0</guid>
      <description>&lt;p&gt;Vs Code Productivity tips and speed hacks - 1&lt;/p&gt;

&lt;p&gt;TL;DR&lt;/p&gt;

&lt;p&gt;Visual Studio Code is like a paint brush, it's only as good as the hands that wields it but unfortunately it has more knobs than a jet and requires the steady hand of a painter. To the untrained eye VS Code is just a simple text editor like Microsoft Word and a Google doc but in reality it contains a ton of productivity boosting features that you're probably not using yet, like...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Terminal Tasks&lt;/li&gt;
&lt;li&gt;Mouse-Less Editing &lt;/li&gt;
&lt;li&gt;Multi-cursor&lt;/li&gt;
&lt;li&gt;Remote Repos&lt;/li&gt;
&lt;li&gt;and etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But here's a thing, every VS Code Pro started as an amateur. In this blog we will compare amateur VS Code techniques to the ones used by pros allowing you to write and analyse your code faster because the most valuable thing you own in this world is your time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We are focusing more on faster approaches, so will not be using the mouse much. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's jump right into the things, assuming you have VS Code installed in you machine. If not try installing it from &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. VS Code CLI
&lt;/h2&gt;

&lt;p&gt;If you want to open a folder in VS Code you directly go into the file explorer right click on the folder and click in &lt;strong&gt;open with VS Code&lt;/strong&gt; that works fine but it would have been much quicker and faster with the CLI &lt;/p&gt;

&lt;p&gt;Faster way - if you're in your terminal and want to open a directory or edit a file you can do it quickly with the CLI using the &lt;code&gt;Code&lt;/code&gt; command like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5fs3s4rledyyqrm7wy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5fs3s4rledyyqrm7wy5.png" alt="Code Command" width="800" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you're in Mac or Linux you need to run this shell command from your VS Code refer &lt;a href="https://code.visualstudio.com/docs/setup/mac" rel="noopener noreferrer"&gt;this&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybjlizz90jjhqur82t3c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybjlizz90jjhqur82t3c.png" alt="Shell Command" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Minimise the use of Mouse
&lt;/h2&gt;

&lt;p&gt;When we have our VS Code window open it is tempting to go around and click on the beautiful buttons provide by VS Code. VS Code allows you to use mouse for each and everything to make things approachable, but that's not the most efficient way to get things done, here is a productivity tip ⚡️ 'The less you rely on the mouse the better.&lt;/p&gt;

&lt;p&gt;You don't have to learn anything like Vim or nano but it's important to understand anything you can do with a mouse is likely to be done by the Keyboard quicker. Vs Code provide keyboard shortcuts for literally everything. All the keyboard shortcuts are customisable. &lt;/p&gt;

&lt;p&gt;Hit &lt;code&gt;Cmd + k Cmd + S&lt;/code&gt; or click on the settings icon in the left panel in VS Code window and boom all the shortcuts are in front of you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjf7ac8t706woqds7jtza.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjf7ac8t706woqds7jtza.png" alt="VS Code Shortcuts" width="800" height="815"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbws4beo3yecq5bsc424t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbws4beo3yecq5bsc424t.png" alt="VS Code Shortcuts" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Use of Command Palette
&lt;/h2&gt;

&lt;p&gt;The first shortcut you should memorise is &lt;code&gt;cmd + p&lt;/code&gt; or &lt;code&gt;ctrl + p&lt;/code&gt; which brings up the command palette. The Command Palette gives you access to a bunch of the powers of the VS Code without actually learning the commands by default it will give you a list of recently opened files &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwfh1hhyo79bheci9nwit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwfh1hhyo79bheci9nwit.png" alt="Command Palette" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition you can start typing a file name that you want to open and that obviously much quicker than trying to find a file from the directories in the file explorer. &lt;/p&gt;

&lt;h3&gt;
  
  
  4. Advanced use of Command Palette
&lt;/h3&gt;

&lt;p&gt;If you type &lt;code&gt;cmd + &amp;gt; + p&lt;/code&gt; or &lt;code&gt;ctrl + &amp;gt; + p&lt;/code&gt; it will give you access to the bunch of command that you can run directly from the command palette with addition to the commands of you downloaded extensions. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa27v9qtjd11vfzgcjoes.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa27v9qtjd11vfzgcjoes.png" alt="Command Palette" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Find by symbols
&lt;/h3&gt;

&lt;p&gt;Another really awesome thing we can do here is find blocks of code throughout our projects, when working in a really big file it is easy to get lost and get confused, the worst thing you can do here is to scroll down the file looking for the functions or interface you need or want to use. &lt;/p&gt;

&lt;h4&gt;
  
  
  - In a file
&lt;/h4&gt;

&lt;p&gt;You could use ctrl foxtrot i.e. &lt;code&gt;ctrl + f&lt;/code&gt; to find the text on the page but let me tell you a little better approach for this, use the &lt;code&gt;@&lt;/code&gt; symbol from the command palette that will list down all the symbols, variables, functions from the code so you can quickly navigate through it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3k7iisfl2113kbiha65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3k7iisfl2113kbiha65.png" alt="@ symbol" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn't is awesome? &lt;/p&gt;

&lt;p&gt;I have another approach too, by using &lt;code&gt;ctrl + shift + .&lt;/code&gt; you can directly bypass the command palette and navigate through all the functions, variables and etc directly from the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9w9xdgy0xkcodmvtznuu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9w9xdgy0xkcodmvtznuu.png" alt="bypass command palette" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  - In the whole project
&lt;/h4&gt;

&lt;p&gt;Now you may need to find a function in the entire project, &lt;br&gt;
you can use &lt;code&gt;ctrl + shift + f&lt;/code&gt; to search something in the entire project, the approach is to use a &lt;code&gt;#&lt;/code&gt; in the command palette. Use a &lt;code&gt;#&lt;/code&gt; in the command palette followed by the name of the function you want to search and boom! all the functions containing the name of function you wrote appears out of no where.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia4rptc7z8uz36etjl1n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia4rptc7z8uz36etjl1n.png" alt="# symbol" width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Command palette is awesome when it comes to productivity boosting. &lt;/p&gt;

&lt;p&gt;This is a series for VS Code productivity hacks and tips, stay tuned for the next blog of the series. &lt;/p&gt;

&lt;p&gt;Let me know in the comments below the productivity hack you use to boost your productivity. &lt;/p&gt;
&lt;h5&gt;
  
  
  Want to connect?
&lt;/h5&gt;

&lt;p&gt;
  
    &lt;a href="https://twitter.com/garimaasharma_" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; ·
    &lt;a href="https://dev.to/garimasharma"&gt;blogs&lt;/a&gt; ·
    &lt;a href="https://garimasharma.netlify.app" rel="noopener noreferrer"&gt;portfolio&lt;/a&gt; ·
    &lt;a href="mailto:sharmagarima814@gmail.com"&gt;email&lt;/a&gt; ·
    &lt;a href="https://www.linkedin.com/in/garima-sharma08/" rel="noopener noreferrer"&gt;linkedin&lt;/a&gt;
  
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>vscode</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Scrape Google SERPs Using WebScrapingAPI in Node.js</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Wed, 01 Sep 2021 08:03:47 +0000</pubDate>
      <link>https://dev.to/garimasharma/how-to-scrape-google-serps-using-webscrapingapi-in-node-js-4f3g</link>
      <guid>https://dev.to/garimasharma/how-to-scrape-google-serps-using-webscrapingapi-in-node-js-4f3g</guid>
      <description>&lt;h2&gt;
  
  
  What is web scraping?
&lt;/h2&gt;

&lt;p&gt;In a nutshell, web scraping means automating the task of collecting useful information from websites. There are many use cases for web scraping, but here are just three ideas: collecting prices from various online stores for a price comparison site, getting flight times and hotel listings for a travel site, even building a search engine like Google!&lt;/p&gt;

&lt;p&gt;Getting started with web scraping is easy, and the process can be broken down into two main parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;acquiring the data using an HTML request library or a headless browser&lt;/li&gt;
&lt;li&gt;parsing the data to get the exact information you want&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is this article about and What are we going to do?
&lt;/h2&gt;

&lt;p&gt;This article is all about showing you how to get data from search engine results pages. To do that, we’ll need a scraper.&lt;/p&gt;

&lt;p&gt;You can use whatever scraping tool you feel most comfortable with. Just know that from here on, the article will focus on how to get the results using &lt;a href="https://www.webscrapingapi.com/" rel="noopener noreferrer"&gt;WebScrapingAPI&lt;/a&gt;. It’s a simple, fast, and reliable REST API that collects HTML from any web page and handles all possible problems in the backend. So, we don’t have to worry about proxy management, Javascript rendering, or CAPTCHAs.&lt;/p&gt;

&lt;p&gt;So, let’s learn how to get the SERP data using &lt;strong&gt;WebScrapingAPI&lt;/strong&gt; in Node.js! &lt;/p&gt;

&lt;h3&gt;
  
  
  What is SERP or SERP data?
&lt;/h3&gt;

&lt;p&gt;Every second, Google processes &lt;strong&gt;60,000+&lt;/strong&gt; searches. That means that this year there will be over &lt;strong&gt;2 trillion&lt;/strong&gt; Google searches.&lt;/p&gt;

&lt;p&gt;Well, that’s a lot of Googling! It also means that as a digital marketer or website developer, it’s more important than ever to understand Google SERP features and how they affect your webpage.&lt;/p&gt;

&lt;p&gt;A SERP or Search Engine Results Page is the result page's data returned by Search Engines. When you type in a keyword into Google, it will fetch the most relevant data, structured into SERPs.&lt;/p&gt;

&lt;p&gt;Besides getting answers to the random questions that might pop into your head, Google SERPs are invaluable for many other reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search Engine Optimization&lt;/li&gt;
&lt;li&gt;Competitor analysis&lt;/li&gt;
&lt;li&gt;Paid ads monitoring &lt;/li&gt;
&lt;li&gt;Keyword research&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, SERP data can help you in two significant ways: keeping an eye on the competition and getting ahead in the search results.&lt;/p&gt;

&lt;p&gt;Sometimes we need more SERP data that can be easily copied manually. In that case, the most efficient way to collect information is to develop algorithms that do if for as. But it’s not always easy as search engines regularly change their SERP structure and search algorithms, meaning that we have to change our own code to match them. No need to panic, though. WebscrapingAPI will help extensively here.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is WebScrapingAPI ?
&lt;/h2&gt;

&lt;p&gt;It’s one of the leading REST APIs for web scraping. &lt;strong&gt;WebScrapingAPI&lt;/strong&gt; collects the HTML from any web page with a simple API call and provides ready-to-process data to everyone in your company or maybe for personal use. It’s easy to integrate into your own scripts, making it a versatile and reliable tool in any developer’s arsenal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Perks of WebScrapingAPI
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you never get blocked&lt;/li&gt;
&lt;li&gt;100M+ rotating proxies at your fingertips&lt;/li&gt;
&lt;li&gt;Easy to use, easy to customize&lt;/li&gt;
&lt;li&gt;Around the globe geotargeting&lt;/li&gt;
&lt;li&gt;99.99% Uptime&lt;/li&gt;
&lt;li&gt;Automatic Scaling&lt;/li&gt;
&lt;li&gt;24/7 Monitoring&lt;/li&gt;
&lt;li&gt;Collect data from any type of webpage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more info, check out &lt;a href="https://app.webscrapingapi.com/" rel="noopener noreferrer"&gt;WebScrapingAPI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So let’s proceed with the tutorial to integrate WebScrapingAPI in Node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use WebScrapingAPI to scrape SERP data
&lt;/h2&gt;

&lt;p&gt;In the following section, we will use Node.js and some libraries like  &lt;a href="https://www.npmjs.com/package/got" rel="noopener noreferrer"&gt;got&lt;/a&gt; and &lt;a href="https://github.com/cheeriojs/cheerio" rel="noopener noreferrer"&gt;Cheerio&lt;/a&gt; to create the script that will get all the data from a SERP and format it nicely to be as understandable as possible. &lt;/p&gt;

&lt;p&gt;Let’s see how all the information presented above can be converted to tangible results:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Get API Access Key
&lt;/h3&gt;

&lt;p&gt;The API Key is required to access the API. So first, we will &lt;a href="https://app.webscrapingapi.com/register" rel="noopener noreferrer"&gt;create an account&lt;/a&gt; and get the &lt;code&gt;API Access Key&lt;/code&gt; from the dashboard.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Register for free at &lt;a href="https://app.webscrapingapi.com/" rel="noopener noreferrer"&gt;webscapingapi.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Get the API access key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can start your &lt;a href="https://www.webscrapingapi.com/pricing/" rel="noopener noreferrer"&gt;free trial&lt;/a&gt; with 5000 requests and access to all functionalities to test the product.&lt;/p&gt;

&lt;p&gt;After successfully creating a free account, access the &lt;strong&gt;API Playground&lt;/strong&gt; page through the button on the dashboard’s left side. The page should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxj8vd7rld6exglbr4vru.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxj8vd7rld6exglbr4vru.png" alt="image1" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the name suggests, this is the place where we can test the scraping tool before creating our script. Let’s copy the URL presented above in the URL input (left column), scroll down a little bit, and smash the &lt;strong&gt;“Send API Request”&lt;/strong&gt; button. This action should return a result that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqubftm31965hvfrzkrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkqubftm31965hvfrzkrf.png" alt="image2" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s build the script that is going to do the work for us.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Check if you have installed node and npm
&lt;/h3&gt;

&lt;p&gt;Run these commands in terminal/Command line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output might look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;v14.16.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get the version as the command’s output, you have already installed node and npm. If you receive any errors, please try installing them from &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt;, and once you have installed Node.js, run &lt;code&gt;npm install -g npm&lt;/code&gt; to install npm and repeat &lt;strong&gt;Step 2&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Set up new npm Package
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will do a lot of the hard work at the back and create a package.json file which will keep track of all the dependencies and DevDependencies we will install throughout our program.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Install the packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i got cheerio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;got cheerio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;a href="https://www.npmjs.com/package/cheerio" rel="noopener noreferrer"&gt;Cheerio&lt;/a&gt; installed, it’ll be much easier to parse the HTML we extract.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Go to your favorite Code Editor/IDE
&lt;/h3&gt;

&lt;p&gt;Let's make a file named serpScraper.js and include the modules into our script to get the results page’s HTML.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;got&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;got&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;If you face any problem using cheerio, sometimes require('packageName').default needs to be exported. So if you get an error about cheerio is not a function or $ is not a function. Try using this:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Use the API Key
&lt;/h3&gt;

&lt;p&gt;We will initialize &lt;code&gt;API Access Key&lt;/code&gt; to create the client to access the API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR_API_KEY_HERE”,
    url: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="na"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//www.google.com/search?q=nodejs&amp;amp;rlz=1C1SQJL_enIN868IN868&amp;amp;oq=nodejs&amp;amp;aqs=chrome.0.69i59l3j69i60j69i61j69i65j69i60j69i61.987j0j7&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8",&lt;/span&gt;
    &lt;span class="na"&gt;country&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;US&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;got&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.webscrapingapi.com/v1?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Storing the results in a variable&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to replace the “YOUR_API_KEY_HERE” string with the &lt;em&gt;API key&lt;/em&gt; provided to you by the service. You can find it on the dashboard page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Inspect the Page
&lt;/h3&gt;

&lt;p&gt;Let’s get back to the page we want to scrape. Right-click on the first heading and click ‘Inspect.’ This is how we can select only the information we need.&lt;/p&gt;

&lt;p&gt;You’ll get a new window containing the HTML source code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We will inspect the heading and get the class-name used to identify the heading from the source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19vog3s3r7umz29fdftu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19vog3s3r7umz29fdftu.png" alt="Alt Text" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For the Heading, we got the class-name &lt;code&gt;h3.LC20lb.DKV0Md&lt;/code&gt;. The heading is contained inside the &lt;code&gt;h3&lt;/code&gt; tag, and the class-name is &lt;code&gt;.LC20lb.DKV0Md&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In &lt;code&gt;.LC20lb.DKV0Md&lt;/code&gt;, &lt;code&gt;.LC20lb&lt;/code&gt; and &lt;code&gt;.DKV0Md&lt;/code&gt; are two different classes. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;We will inspect the link and get the class-name used to identify the paragraph from the source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1ng0xn9un9mkw1duidi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1ng0xn9un9mkw1duidi.png" alt="Alt Text" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7j02ylaz3fc1277uxke8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7j02ylaz3fc1277uxke8.png" alt="Alt Text" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the links we got class-name as &lt;code&gt;yuRUbf&lt;/code&gt; which contain another &lt;code&gt;a&lt;/code&gt; tag inside of it. So we will use this syntax to get the link from the page &lt;code&gt;.yuRUbf &amp;gt; a&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 8: Store the headings and links in separate arrays
&lt;/h3&gt;

&lt;p&gt;As we have already inspected and got to know the class-name of the heading and link, we can now extract the information from the source code. We can go through and grab a list of links to all Node.js topics by getting them from each element’s “attribs” section.&lt;/p&gt;

&lt;p&gt;Let's use them to extract the headings and links.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h3.LC20lb.DKV0Md&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;headings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.yuRUbf &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;attribs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h3.LC20lb.DKV0Md&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 9: Format the information
&lt;/h3&gt;

&lt;p&gt;As we have extracted the information from the source code, we need to format it in a human-readable format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt; :- &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 10: Put it all together.
&lt;/h3&gt;

&lt;p&gt;Here is the complete code to make &lt;strong&gt;WebScrapingAPI&lt;/strong&gt; request and get response result data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;got&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;got&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR_API_KEY_HERE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://www.google.com/search?q=nodejs&amp;amp;rlz=1C1SQJL_enIN868IN868&amp;amp;oq=nodejs&amp;amp;aqs=chrome.0.69i59l3j69i60j69i61j69i65j69i60j69i61.987j0j7&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;country&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;US&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;got&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.webscrapingapi.com/v1?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;searchParams&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h3.LC20lb.DKV0Md&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;headings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.yuRUbf &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;attribs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h3.LC20lb.DKV0Md&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt; :- &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;displayResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Node.js :- https://nodejs.org/
2. Node.js - Wikipédia :- https://fr.wikipedia.org/wiki/Node.js
3. NodeJs : le guide complet pour tout comprendre du javascript ... :- https://practicalprogramming.fr/nodejs
4. Qu'est-ce que Node.js et pourquoi l'utiliser ? - Kinsta :- https://kinsta.com/fr/base-de-connaissances/qu-est-ce-que-node-js/
5. Apprendre NodeJS | Grafikart :- https://grafikart.fr/tutoriels/nodejs
6. Tutoriel : Node.js sur Windows pour débutants | Microsoft Docs :- https://docs.microsoft.com/fr-fr/windows/dev-environment/javascript/nodejs-beginners-tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, scraping SERP data using &lt;strong&gt;WebScrapingAPI&lt;/strong&gt; is quite easy. We have to use a scraping API to get the HTML content, parse the response, get the relevant information from each element on the page and console everything or store it in arrays or json format.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The results might differ depending on the location of the proxy. The results stated above are for a US proxy but if you choose a proxy from another location results will be different. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;To take your startup or business to their peak nowadays takes a lot more than having a great product. There are endless opportunities depending on how creative you can be. Some of the most important and healthy strategies business owners should pay attention to are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creating an online presence;&lt;/li&gt;
&lt;li&gt;knowing the Substitutes for and Complimentary products to your own;&lt;/li&gt;
&lt;li&gt;working on providing the most value for the lowest price;&lt;/li&gt;
&lt;li&gt;knowing about the demand and supply for your product- this helps in knowing when to modify the pricing according to the demand and supply chains;&lt;/li&gt;
&lt;li&gt;having a complete understanding of the competition’s advantage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these strategies can prove vital in one’s business. It feels good to know that web scrapers offer a huge help in tackling these problems. Adding automation to the data gathering process may be the easiest step to improve their business.&lt;/p&gt;

&lt;p&gt;We try to offer a helping hand by creating the necessary tools for these kinds of jobs. Thank you for reading the article, and remember that &lt;a href="https://www.webscrapingapi.com/pricing/" rel="noopener noreferrer"&gt;you can use this code too with a WebScrapingAPI free trial&lt;/a&gt;. Give it a spin and see if it works well for your use case!&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.webscrapingapi.com/#introduction" rel="noopener noreferrer"&gt;WebScrapingAPI Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.webscrapingapi.com/docs/" rel="noopener noreferrer"&gt;WebScrapingAPI Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kb.webscrapingapi.com/article/11-webscrapingapi-with-javascript" rel="noopener noreferrer"&gt;Using WebScrapingAPI with Javascript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kb.webscrapingapi.com/" rel="noopener noreferrer"&gt;More articles on WebScrapingAPI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>webscraping</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Ultimate Guide to Web Scraping with Node.js</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Tue, 17 Aug 2021 08:33:19 +0000</pubDate>
      <link>https://dev.to/garimasharma/the-ultimate-guide-to-web-scraping-with-node-js-bn3</link>
      <guid>https://dev.to/garimasharma/the-ultimate-guide-to-web-scraping-with-node-js-bn3</guid>
      <description>&lt;h2&gt;
  
  
  What is web scraping?
&lt;/h2&gt;

&lt;p&gt;It involves automating the task of collecting information from websites.&lt;/p&gt;

&lt;p&gt;There are a lot of use cases for web scraping you might want to collect prices from various e-commerce sites for a price comparison site. Or perhaps you need flight times and hotel listings for a travel site. Maybe you want to collect emails from various directories for sales leads, Or you could even be wanting to build a search engine like Google!&lt;/p&gt;

&lt;p&gt;Getting started with web scraping is easy, and the process can be broken down into two main parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;acquiring the data using an HTML request library or a headless browser(maybe we will check this out in another post),&lt;/li&gt;
&lt;li&gt;and parsing the data to get the exact information you want.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide will walk you through the process with the popular Node.js &lt;a href="https://github.com/request/request-promise" rel="noopener noreferrer"&gt;request-promise&lt;/a&gt; module, &lt;a href="https://github.com/cheeriojs/cheerio" rel="noopener noreferrer"&gt;CheerioJS&lt;/a&gt;, and &lt;a href="https://github.com/puppeteer/puppeteer" rel="noopener noreferrer"&gt;Puppeteer&lt;/a&gt;. Working through the examples in this post, we will learn all the tips and tricks you need to become a pro at gathering any data you need with Node.js!&lt;/p&gt;

&lt;p&gt;We will be gathering a list of all the names and birthdays of Indian presidents from Wikipedia.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's do it step by step
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Check if you have installed node and npm in your system.&lt;br&gt;
Run these commands in terminal/Command line&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;if you get the version as the output of the command you have already installed &lt;em&gt;node&lt;/em&gt; and &lt;em&gt;npm&lt;/em&gt;,if you receive any error please try installing them. Output might look like&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;v14.16.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Set up new npm Package&lt;br&gt;
Run command&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This command will do a alot of hardwork at the back and create a &lt;em&gt;package.json&lt;/em&gt; file which will keep a track of all the dependencies and DevDependencies we will install throughout our program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Making your first request&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; request request-promise cheerio puppeteer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save&lt;/span&gt; request request-promise cheerio puppeteer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;-D&lt;/em&gt; and &lt;em&gt;--save&lt;/em&gt; tags are used to install npm module as DevDependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Puppeteer will take a while to install as it needs to download Chromium as well or you can skip this because we are not using puppeteer in our program yet. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Go to your favorite Code Editor/IDE &lt;br&gt;
Let's make a file named &lt;strong&gt;scraper.js&lt;/strong&gt;, and write a quick function to get the HTML of the Wikipedia “List of Presidents” page.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://en.wikipedia.org/wiki/List_of_presidents_of_India&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&amp;lt;&lt;span class="o"&gt;!&lt;/span&gt;DOCTYPE html&amp;gt;
&amp;lt;html &lt;span class="nv"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"client-nojs"&lt;/span&gt; &lt;span class="nv"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"en"&lt;/span&gt; &lt;span class="nb"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ltr"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span class="nb"&gt;head&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&amp;lt;meta &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"UTF-8"&lt;/span&gt;/&amp;gt;
&amp;lt;title&amp;gt;List of Presidents of the India - Wikipedia&amp;lt;/title&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Using Chrome DevTools
&lt;/h4&gt;

&lt;p&gt;Cool, we got the raw HTML from the web page! But now we need to make sense of this giant blob of text. To do that, we’ll need to use Chrome DevTools to allow us to easily search through the HTML of a web page.&lt;/p&gt;

&lt;p&gt;Using Chrome DevTools is easy: simply open Google Chrome, and right click on the element you would like to scrape &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnijppg20ny15rzu6l92g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnijppg20ny15rzu6l92g.png" alt="Chrome DevTools" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, simply click inspect, and Chrome will bring up its DevTools pane, allowing you to easily inspect the page’s source HTML.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7gutt4l5glz9dg6k25n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7gutt4l5glz9dg6k25n.png" alt="ChromeDevtools2t" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After inspecting the name of the President of India, we came to know that the names are stored inside the &lt;strong&gt;th&lt;/strong&gt; tag wrapped in an &lt;strong&gt;anchor tag&lt;/strong&gt;. So let's use it then !&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Parsing HTML with &lt;strong&gt;CheerioJS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://en.wikipedia.org/wiki/List_of_presidents_of_India&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;th &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;th &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;18
&lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'0'&lt;/span&gt;:
  &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;: &lt;span class="s1"&gt;'tag'&lt;/span&gt;,
    name: &lt;span class="s1"&gt;'a'&lt;/span&gt;,
    attribs: &lt;span class="o"&gt;{&lt;/span&gt; href: &lt;span class="s1"&gt;'/wiki/Rajendra_Prasad'&lt;/span&gt;, title: &lt;span class="s1"&gt;'Rajendra Prasad'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
    children: &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;Object] &lt;span class="o"&gt;]&lt;/span&gt;,
    next: null,
    prev: null,
    parent:
      &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;: &lt;span class="s1"&gt;'tag'&lt;/span&gt;,
        name: &lt;span class="s1"&gt;'big'&lt;/span&gt;,
        attribs: &lt;span class="o"&gt;{}&lt;/span&gt;,
        children: &lt;span class="o"&gt;[&lt;/span&gt;Array],
        next: null,
        prev: null,
        parent: &lt;span class="o"&gt;[&lt;/span&gt;Object] &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="s1"&gt;'1'&lt;/span&gt;:
    &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;: &lt;span class="s1"&gt;'tag'&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Note:
&lt;/h3&gt;

&lt;p&gt;I was facing some problem using cheerio and found out that sometimes require('packageName').default needs to be exported. So if you get an error about &lt;strong&gt;cherrio is not function or $ is not a function&lt;/strong&gt;. Try using this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;It worked for me!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Getting the names of all the Presidents.&lt;/p&gt;

&lt;p&gt;We check to make sure there are exactly 18 elements returned (the number of Indian presidents), meaning there aren’t any extra hidden “th” tags elsewhere on the page. Now, we can go through and grab a list of links to all 18 presidential Wikipedia pages by getting them from the “attribs” section of each element.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://en.wikipedia.org/wiki/List_of_presidents_of_India&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;presidentUrls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;th &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;presidentUrls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;th &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;attribs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;presidentUrls&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;
  &lt;span class="s1"&gt;'/wiki/Rajendra_Prasad'&lt;/span&gt;,
  &lt;span class="s1"&gt;'/wiki/Sir Sarvepalli_Radhakrishnan'&lt;/span&gt;,
  &lt;span class="s1"&gt;'/wiki/Zakir_Husain'&lt;/span&gt;,
  &lt;span class="s1"&gt;'/wiki/V._V._Giri'&lt;/span&gt;,
  &lt;span class="s1"&gt;'/wiki/Mohammad_Hidayatullah'&lt;/span&gt;,
  &lt;span class="s1"&gt;'/wiki/V._V._Giri'&lt;/span&gt;,
  &lt;span class="s1"&gt;'/wiki/Fakhruddin_Ali_Ahmed'&lt;/span&gt;,
  ...
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Let's grab their birthdays from the html page.&lt;/p&gt;

&lt;p&gt;Now we have a list of all 18 presidential Wikipedia pages. Let’s create a new file (named scrapParse.js), which will contain a function to take a presidential Wikipedia page and return the president’s name and birthday. First things first, let’s get the raw HTML from Rajendra Prasad’s Wikipedia page.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://en.wikipedia.org/wiki/Rajendra_Prasad&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&amp;lt;html &lt;span class="nv"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"client-nojs"&lt;/span&gt; &lt;span class="nv"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"en"&lt;/span&gt; &lt;span class="nb"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ltr"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&amp;lt;&lt;span class="nb"&gt;head&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&amp;lt;meta &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"UTF-8"&lt;/span&gt;/&amp;gt;
&amp;lt;title&amp;gt;Rajendra Prasad - Wikipedia&amp;lt;/title&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let’s once again use Chrome DevTools to find the syntax of the code we want to parse, so that we can extract the name and birthday with Cheerio.js.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gxo7hhd62wye4kaaobv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gxo7hhd62wye4kaaobv.png" alt="Alt Text" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqigh8ld3hclxjviaxvf5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqigh8ld3hclxjviaxvf5.png" alt="Alt Text" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we see that the name is in a class called “firstHeading” and the birthday is in a class called “bday”. Let’s modify our code to use Cheerio.js to extract these two classes.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://en.wikipedia.org/wiki/Rajendra_Prasad&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.firstHeading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.bday&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Rajendra Prasad
1884-12-03
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Putting it all together&lt;br&gt;
Now let’s wrap this up into a function and export it from this module.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scrapParse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.firstHeading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="na"&gt;birthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.bday&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;scrapParse&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now let’s return to our original file Scraper.js and require the &lt;em&gt;scrapParse.js&lt;/em&gt; module. We’ll then apply it to the list of presidentUrls we gathered earlier.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;request-promise&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;scrapParse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scrapParse&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://en.wikipedia.org/wiki/List_of_presidents_of_India&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cheerio&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;rp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;presidentUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;th &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;presidentUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;th &amp;gt; a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;attribs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;presidentUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;scrapParse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`https://en.wikipedia.org&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;presidents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;presidents&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Rajendra Prasad'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1884-12-03'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Sarvepalli Radhakrishnan'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1888-09-05'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Zakir Husain (politician)'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1897-02-08'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'V. V. Giri'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1894-08-10'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'V. V. Giri'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1894-08-10'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Fakhruddin Ali Ahmed'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1905-05-13'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'B. D. Jatti'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1912-09-10'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Neelam Sanjiva Reddy'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1913-05-19'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Zail Singh'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1916-05-05'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Zail Singh'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1916-05-05'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Zail Singh'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1916-05-05'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Ramaswamy Venkataraman'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1910-12-04'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Shankar Dayal Sharma'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1918-08-19'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'K. R. Narayanan'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1997-07-25'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'A. P. J. Abdul Kalam'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1931-10-15'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Pratibha Patil'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1934-12-19'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Pranab Mukherjee'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1935-12-11'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt; name: &lt;span class="s1"&gt;'Ram Nath Kovind'&lt;/span&gt;, birthday: &lt;span class="s1"&gt;'1945-10-01'&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Additional Resources
&lt;/h3&gt;

&lt;p&gt;And there’s the list! At this point you should feel comfortable writing your first web scraper to gather data from any website. Here are a few additional resources that you may find helpful during your web scraping journey:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.scraperapi.com/blog/the-10-best-rotating-proxy-services-for-web-scraping/" rel="noopener noreferrer"&gt;List of web scraping proxy services&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scraperapi.com/blog/5-tips-for-web-scraping/" rel="noopener noreferrer"&gt;List of handy web scraping tools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scraperapi.com/blog/5-tips-for-web-scraping/" rel="noopener noreferrer"&gt;List of web scraping tips&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scraperapi.com/blog/free-shared-dedicated-datacenter-residential-rotating-proxies-for-web-scraping/" rel="noopener noreferrer"&gt;Comparison of web scraping proxies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/cheeriojs/cheerio" rel="noopener noreferrer"&gt;Cheerio Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/puppeteer/puppeteer" rel="noopener noreferrer"&gt;Puppeteer Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/the-ultimate-guide-to-web-scraping-with-node-js-daa2027dcd3/" rel="noopener noreferrer"&gt;Guide to web Scrapping&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.scraperapi.com/resources/white-paper-web-scraping-basics/" rel="noopener noreferrer"&gt;Web Scraping white paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Some beginner-friendly recommended APIs for Web Scraping
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.scraperapi.com/" rel="noopener noreferrer"&gt;Scraper API&lt;/a&gt; - An API with Web scraping benefits and processes with multiple types of data collection. Helps in handling proxies, browsers, and CAPTCHAs, so you can get the HTML from any web page with a simple API call.&lt;/p&gt;

&lt;p&gt;Suggestions and corrections are most welcome❤️.&lt;br&gt;
Get the Code: &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Garima-sharma814" rel="noopener noreferrer"&gt;
        Garima-sharma814
      &lt;/a&gt; / &lt;a href="https://github.com/Garima-sharma814/Web-Scraper" rel="noopener noreferrer"&gt;
        Web-Scraper
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Simple Web scraping app to scrape all the Indian Presidents (Name and Birthdays) present on Wikipedia.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;What is Web Scraping?&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;In a nutshell, web scraping means automating the task of collecting useful information from websites. There are many use cases for web scraping, but here are just three ideas: collecting prices from various online stores for a price comparison site, getting flight times and hotel listings for a travel site, even building a search engine like Google!&lt;/p&gt;

&lt;p&gt;This repository will walk you through the process with the popular Node.js &lt;a href="https://github.com/request/request-promise" rel="noopener noreferrer"&gt;request-promise&lt;/a&gt; module, &lt;a href="https://github.com/cheeriojs/cheerio" rel="noopener noreferrer"&gt;CheerioJS&lt;/a&gt;, and &lt;a href="https://github.com/puppeteer/puppeteer" rel="noopener noreferrer"&gt;Puppeteer&lt;/a&gt;. Working through the examples in this post, we will learn all the tips and tricks you need to become a pro at gathering any data you need with Node.js!&lt;/p&gt;

&lt;p&gt;We will be gathering a list of all the names and birthdays of Indian presidents from Wikipedia.&lt;/p&gt;

&lt;p&gt;To know how to do it step by step read my blog &lt;a href="https://dev.to/garimasharma/the-ultimate-guide-to-web-scraping-with-node-js-bn3" rel="nofollow"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Garima-sharma814/Web-Scraper" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;Written and edited by &lt;a href="https://twitter.com/garimavatss" rel="noopener noreferrer"&gt;me&lt;/a&gt;❤️ &lt;/p&gt;

</description>
      <category>node</category>
      <category>webscraping</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>CSS- The Cascade !</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Thu, 01 Jul 2021 05:49:58 +0000</pubDate>
      <link>https://dev.to/garimasharma/css-the-cascade-8i0</link>
      <guid>https://dev.to/garimasharma/css-the-cascade-8i0</guid>
      <description>&lt;p&gt;Sometimes two or more competing CSS rules are applied to a particular element. In this post we will find out how browser choose which property to use for the element and how to control it.&lt;/p&gt;

&lt;p&gt;CSS stands for Cascading Stylesheets. The Cascade is the algorithm for solving conflicts where multiple CSS rules are applied to an HTML element. If we have this &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt; Let's Check which color is chosen by the browser &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/garima-sharma814/embed/QWvwRRq?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So why this happened ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Understanding the cascade algorithm helps us understand how the browser resolves the conflicts like these .. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Cascade can split into 4 stages
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Position and order of appearance&lt;/strong&gt; :- The order in which the CSS rule appear in the Stylesheet. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Specificity&lt;/strong&gt; :- An algorithm which determines which CSS property have strongest preference.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Origin:&lt;/strong&gt; the order of when CSS appears and where it comes from, whether that is a browser style, CSS from a browser extension, or your authored CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Importance&lt;/strong&gt; :- some CSS rules are weighted more heavily than others, especially with the &lt;code&gt;!important&lt;/code&gt; rule type.&lt;/p&gt;

&lt;h2&gt;
  
  
  Position and Order of Appearance
&lt;/h2&gt;

&lt;p&gt;The order in which our CSS rules appear in the Stylesheet and their appearance is always taken into consideration by the cascade to calculate the conflicts if any. &lt;/p&gt;

&lt;p&gt;The demo right at the start of this blog is the most straightforward example of positioning. There are two rules that have selectors of identical specificity, so the last one to be declared won.&lt;/p&gt;

&lt;p&gt;Styles can come from various sources on an HTML page, such as a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag, an embedded &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag, and inline CSS as defined in an element's style attribute.&lt;/p&gt;

&lt;p&gt;If you have a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; that includes CSS at the top of your HTML page, then another &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; that includes CSS at the bottom of your page, the bottom &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; will have the most preference. The same thing happens with embedded &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; elements, too. They get more specific, the further down the page they are.&lt;/p&gt;

&lt;p&gt;This ordering also applies to embedded &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; elements. If they are declared before a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt;, the linked stylesheet's CSS will have the most specificity.&lt;/p&gt;

&lt;p&gt;An inline style attribute with CSS declared in it will override all other CSS, regardless of its position, unless a declaration has &lt;code&gt;!important&lt;/code&gt; defined.&lt;/p&gt;

&lt;p&gt;Position also applies in the order of your CSS rule. In this example, the element will have a purple background because background: purple was declared last. Because the green background was declared before the purple background, it is now ignored by the browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;purple&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Specificity
&lt;/h2&gt;

&lt;p&gt;Specificity is an algorithm which determines which CSS selector is the most specific, those calculations. By making a rule more specific, you can cause it to be applied even if some other CSS that matches the selector appears later in the CSS.&lt;/p&gt;

&lt;p&gt;Suppose that we are working this HTML and CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello, Specificity!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's two competing rules here. One will color the button red and the other will color it blue. &lt;/p&gt;

&lt;p&gt;Which rule gets applied to the element? &lt;br&gt;
Understanding the CSS specification's algorithm about specificity is the key to understanding how CSS decides between competing rules.&lt;/p&gt;

&lt;p&gt;Specificity is one of the four distinct stages of the cascade.&lt;/p&gt;
&lt;h3&gt;
  
  
  Preference of Selectors from lowest to highest
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Universal Selector&lt;/strong&gt;&lt;br&gt;
A universal selector (*) has no specificity and gets 0 points. This means that any rule with 1 or more points will override it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We usually use this to reset the default properties of CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Element or pseudo-element selector&lt;/strong&gt;&lt;br&gt;
An element (type) or &lt;a href="https://dev.to/garimasharma/pseudo-classes-and-pseudo-elements-npp"&gt;pseudo-element&lt;/a&gt; selector gets 1 point of specificity .&lt;/p&gt;
&lt;h4&gt;
  
  
  Type selector
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Pseudo-element selector
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;::selection&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;3. Class, pseudo-class, or attribute selector&lt;/strong&gt;&lt;br&gt;
A class, pseudo-class or attribute selector gets 10 points of specificity.&lt;/p&gt;
&lt;h4&gt;
  
  
  Class selector
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Pseudo-class selector
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Attribute selector
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;'#'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The :not() pseudo-class itself adds nothing to the specificity calculation. However, the selectors passed in as arguments do get added to the specificity calculation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;.my-class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example would have 11 points of specificity because it has one type selector (div) and one class inside the :not().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. ID selector&lt;/strong&gt;&lt;br&gt;
An ID selector gets 100 points of specificity, as long as you use an ID selector (#myID) and not an attribute selector ([id="myID"]).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#myID&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Inline style attribute&lt;/strong&gt;&lt;br&gt;
CSS applied directly to the style attribute of the HTML element, gets a specificity score of 1,000 points. This means that in order to override it in CSS, you have to write an extremely specific selector.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. !important rule&lt;/strong&gt;&lt;br&gt;
Lastly, an !important at the end of a CSS value gets a specificity score of 10,000 points. This is the highest specificity that one individual item can get.&lt;/p&gt;

&lt;p&gt;An !important rule is applied to a CSS property, so everything in the overall rule (selector and properties) does not get the same specificity score.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* 10,000 points */&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* 10 points */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are a lot of &lt;a href="https://dev.to/garimasharma/css-selectors-3co4"&gt;Selectors&lt;/a&gt; with their specificities for more go to references.&lt;/p&gt;

&lt;p&gt;References&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity" rel="noopener noreferrer"&gt;MDN specificity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://specifishity.com/" rel="noopener noreferrer"&gt;CSS SpciFISHity&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Windows 11 browser layout</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Mon, 28 Jun 2021 05:54:15 +0000</pubDate>
      <link>https://dev.to/garimasharma/windows-11-browser-layout-403f</link>
      <guid>https://dev.to/garimasharma/windows-11-browser-layout-403f</guid>
      <description>&lt;p&gt;I just tried to make windows 11 layout in browser with HTML, CSS and JAVASCRIPT. &lt;/p&gt;

&lt;p&gt;Windows 11 provides a calm and creative space where you can pursue your passions through a fresh experience. From a rejuvenated Start menu to new ways to connect to your favorite people, news, games, and content—Windows 11 is the place to think, express, and create in a natural way.&lt;/p&gt;

&lt;p&gt;Looking forward to m add more functionalities to make this browser layout more similar to Windows11. &lt;/p&gt;

&lt;p&gt;Contributions and suggestions are Welcome ❤&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you feel like contributing to this go to &lt;a href="https://github.com/Garima-sharma814/windows11-browser-clone" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt; and create &lt;a href="https://github.com/Garima-sharma814/windows11-browser-clone/pulls" rel="noopener noreferrer"&gt;Pull Request&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Garima-sharma814/windows11-browser-clone" rel="noopener noreferrer"&gt;See the code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://windows11clone.netlify.app/" rel="noopener noreferrer"&gt;Final output&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Garima-sharma814" rel="noopener noreferrer"&gt;
        Garima-sharma814
      &lt;/a&gt; / &lt;a href="https://github.com/Garima-sharma814/windows11-browser-clone" rel="noopener noreferrer"&gt;
        windows11-browser-clone
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Windows 11 browser clone made with  HTML, CSS, JAVASCRIPT. 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Windows11-browser-clone&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;Windows 11 browser layout made with Html, Css and JavaScript.
Looking forward to add more functionalitites.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Contributions are welcome ✨&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Garima-sharma814/windows11-browser-clone" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>showdev</category>
      <category>html</category>
      <category>css3</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Pseudo-classes and pseudo-elements</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Thu, 24 Jun 2021 12:27:32 +0000</pubDate>
      <link>https://dev.to/garimasharma/pseudo-classes-and-pseudo-elements-npp</link>
      <guid>https://dev.to/garimasharma/pseudo-classes-and-pseudo-elements-npp</guid>
      <description>&lt;p&gt;CSS provide useful selector types that focus on specific platform state, like when the element is hovered, active etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pseudo-Classes
&lt;/h2&gt;

&lt;p&gt;HTML here find themselves in various stages either because they are interacted with user or one of their child element is in a certain state. &lt;/p&gt;

&lt;p&gt;For example, an HTML element could be hovered with the mouse pointer by a user or a child element could also be hovered by the user. For those situations, use the &lt;code&gt;:hover&lt;/code&gt; pseudo-class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/*When the link is hovered with a mouse pointer this code is fired*/&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;underline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Pseudo-classes let you apply CSS based on state changes. This means that your design can react to user input and changes accordingly.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example &lt;br&gt;
you have an email signup form, you can change the border color of the field to red, if it contains invalid email address and green when it contains correct email address.&lt;/p&gt;

&lt;p&gt;As stated above pseudo-class let us apply CSS based on user input. Entering an email address is the input of the user. (whether right or wrong)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you do that?&lt;/strong&gt;&lt;br&gt;
Well, we have a pseudo-class &lt;code&gt;:invalid&lt;/code&gt;, this is one of many browser-provided &lt;strong&gt;pseudo-class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/garima-sharma814/embed/MWpNWqJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;A pseudo-class lets you apply styles based on state changes and external factors. This means that your design can react to user input such as an invalid email address. &lt;/p&gt;

&lt;h3&gt;
  
  
  Interactive States
&lt;/h3&gt;

&lt;p&gt;We can apply the following pseudo-classes on the interaction of a user with our page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;:hover&lt;/strong&gt;
If the user is pointing to an element with a pointing device (can be a mouse), an they place it over an element, we can trigger the action of the user with &lt;code&gt;:hover&lt;/code&gt; class to apply different style when user &lt;em&gt;hovers&lt;/em&gt; on it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/garima-sharma814/embed/mdWNdZZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We can achieve this effect with little effort&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt; This is link &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; Try hovering me! &lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/*This line is to remove the default behavior of anchor tag we want underline effect one hover */&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*When the user hover on a tag this code will be fired*/&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;underline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#8e44ad&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;:active&lt;/strong&gt;
This state is triggered when an element is actively being interacted with— such as a click—before click is released. If a pointing device like a mouse is used, this state is when the click starts and hasn't yet been released.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/garima-sharma814/embed/QWpewNd?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We can achieve this effect with little effort&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Click and hold to see the active state&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.99&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are tons of pseudo-classes for us to explore on. If you want to know more go to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes" rel="noopener noreferrer"&gt;Pseudo-classes&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pseudo-Elements
&lt;/h2&gt;

&lt;p&gt;Pseudo-elements differ from pseudo-classes because instead of responding to the platform state, they act as if they are inserting a new element with CSS. Pseudo-elements are also syntactically different from pseudo-classes, because instead of using a single colon (:), we use a double colon (::).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A pseudo-element is like adding or targeting an extra element without having to add more HTML. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example&lt;br&gt;
If you've got an article of content and you want the first letter to be a much bigger drop cap— how do you achieve that?&lt;/p&gt;

&lt;p&gt;In CSS, you can use the &lt;code&gt;::first-letter&lt;/code&gt; pseudo-element to achieve this sort of design detail.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;::first-letter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;left&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.6em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/garima-sharma814/embed/yLMmyjK?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;::before and ::after&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both the &lt;code&gt;::before&lt;/code&gt; and &lt;code&gt;::after&lt;/code&gt; pseudo-elements create a child element inside an element only if you define a content property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-element&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-element&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;::before&lt;/code&gt; pseudo-element to insert content at the start of an element, or the &lt;code&gt;::after&lt;/code&gt; pseudo-element to insert content at the end of an element.&lt;/p&gt;

&lt;p&gt;Pseudo-elements aren't limited to inserting content, though. We can also use them to target specific parts of an element.&lt;/p&gt;

&lt;p&gt;The content can be any string even an empty one but be mindful that anything other than an empty string will likely be announced by a screen reader. We can add an image &lt;code&gt;url&lt;/code&gt;, which will insert an image at its original dimensions, so we won't be able to resize it.&lt;/p&gt;

&lt;p&gt;There are tons of pseudo-classes for us to explore on. If you want to know more go to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements" rel="noopener noreferrer"&gt;Pseudo-Elements&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Written and Edited by &lt;a href="https://twitter.com/garimavatss" rel="noopener noreferrer"&gt;me&lt;/a&gt;❤.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>CSS Selectors</title>
      <dc:creator>Garima</dc:creator>
      <pubDate>Mon, 14 Jun 2021 06:30:18 +0000</pubDate>
      <link>https://dev.to/garimasharma/css-selectors-3co4</link>
      <guid>https://dev.to/garimasharma/css-selectors-3co4</guid>
      <description>&lt;p&gt;To apply CSS to an element you need to select it. CSS provides you with a number of different ways to do this, and you can explore them in this post.&lt;/p&gt;

&lt;p&gt;If you have got some text that you want to render in Red or any other color How would you do that?&lt;br&gt;
for ex you have this element&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt; This is first paragraph in this div which is to be rendered in Red Color&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt; This is second paragraph in this div which is normal &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You use a CSS selector to find that specific element and apply a CSS rule, like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;:first-of-type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS provides us a lot of options to select elements and apply specific rules to them, ranging from very simple to very complex, to help us to tackle situations like this.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/garima-sharma814/embed/yLMQKyG?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Parts of CSS rules
&lt;/h2&gt;

&lt;p&gt;To understand how selectors work and their role in CSS, it's important to know the parts of a CSS rule. A CSS rule is a block of code, containing one or more selectors and one or more declarations of property which we want to make change in our HTML element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwp7i6rfhvc9sbiwf3e7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwp7i6rfhvc9sbiwf3e7.png" alt="image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this image, the selector is &lt;code&gt;.my-css-rule&lt;/code&gt; which finds all elements with a class of &lt;code&gt;my-css-rule&lt;/code&gt; on the page. There are three declarations within the curly brackets. A declaration is a property and value pair which applies styles to the elements matched by the selectors. A CSS rule can have as many declarations and selectors as you like.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Selectors
&lt;/h2&gt;

&lt;p&gt;The most simple selectors of CSS are targeting the element by classes, ID and other attributes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Universal Selectors
&lt;/h3&gt;

&lt;p&gt;A universal selector is a selector which selects all the elements in HMTL file. Universal Selector is also known as wildcard. It matches all the elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This rule will apply on each and every element of the HTML file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type Selectors
&lt;/h3&gt;

&lt;p&gt;Type selectors directly targets the HMTL element by its type/tag i.e. div, section etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This rule cause every &lt;/p&gt;
&lt;p&gt; tag to render in red color.&lt;/p&gt;

&lt;h3&gt;
  
  
  Class Selectors
&lt;/h3&gt;

&lt;p&gt;An HTML element can have more than one class at a time. The class selector will target every element having that class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"test-class"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; This is just a div &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can select this div with its class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.test-class&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CSS , class is selected by a &lt;code&gt;.&lt;/code&gt; this dot is not present in the HTML element. This means &lt;code&gt;.&lt;/code&gt; is a character which instructs CSS to target all the elements having class &lt;code&gt;test-class&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A HTML element that has a class of .test-class will still be matched to the above CSS rule, even if they have several other classes, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"test-class another-class some-other-classes"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Id Selectors
&lt;/h3&gt;

&lt;p&gt;An HTML element with an &lt;code&gt;id&lt;/code&gt; attribute should be the only element on a page with that ID value. An HTML element should not have more than 1 ID at a time (&lt;em&gt;good practices&lt;/em&gt;) and if you have more than 1 ID in an element you code might break. You select elements with an ID selector like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"test-id"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can select this div with this ID&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#test-id&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As seen in the class selector we can select the id by the &lt;code&gt;#&lt;/code&gt; symbol. &lt;code&gt;#&lt;/code&gt; symbol instructs CSS to target the element having this ID.&lt;/p&gt;

&lt;h3&gt;
  
  
  Grouping Selectors
&lt;/h3&gt;

&lt;p&gt;A selector doesn't have to match only a single element. You can group multiple selectors by separating them with commas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h4&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h5&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h6&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.test-class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;#test-id&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Complex selectors
&lt;/h3&gt;

&lt;p&gt;You have already seen a lot of selectors, but sometimes, you will need more fine-grained control with your CSS. This is where complex selectors step in to help.&lt;/p&gt;

&lt;p&gt;It's worth remembering at this point that although the following selectors give us more power, we can only cascade downwards, selecting child elements. We are not able to target upwards and select a parent element.&lt;/p&gt;

&lt;h4&gt;
  
  
  Combinators
&lt;/h4&gt;

&lt;p&gt;A combinator is an element which resides inside another element. For ex &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag can reside inside a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag. &lt;/p&gt;

&lt;h4&gt;
  
  
  Descendant Combinators
&lt;/h4&gt;

&lt;p&gt;Let's understand the relationship in Child and Parent tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;A paragraph of text with some &lt;span class="nt"&gt;&amp;lt;strong&amp;gt;&lt;/span&gt; bold text for emphasis /strong&amp;gt;.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parent element is &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag child element is the &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag. We can understand this because &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag sits inside the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag. So, &lt;/p&gt;
&lt;p&gt; tag is the direct parent of &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;A descendant combinator allows us to target the child element with the help of the parent tag. This use space to instruct about the parent-child relationship.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;strong&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This rule will select all the &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; tag which resides inside a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag. &lt;/p&gt;

&lt;h4&gt;
  
  
  Compound Selectors
&lt;/h4&gt;

&lt;p&gt;You can combine selectors to increase specificity and readability. For example, to target &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; elements, that also have a class of .my-class, write the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nc"&gt;.my-class&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://web.dev/learn/css/selectors/#simple-selectors" rel="noopener noreferrer"&gt;Learn CSS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/garimasharma" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.buymeacoffee.com%2Fbutton-api%2F%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dgarimasharma%26button_colour%3DFF5F5F%26font_colour%3Dffffff%26font_family%3DArial%26outline_colour%3D000000%26coffee_colour%3DFFDD00" width="235.0" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
