<?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: Mehul Mohan</title>
    <description>The latest articles on DEV Community by Mehul Mohan (@mehulmpt).</description>
    <link>https://dev.to/mehulmpt</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%2F89486%2Ffb689435-5429-484a-a081-5a2e50e7660a.jpeg</url>
      <title>DEV Community: Mehul Mohan</title>
      <link>https://dev.to/mehulmpt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mehulmpt"/>
    <language>en</language>
    <item>
      <title>Gift-a-thon by codedamn</title>
      <dc:creator>Mehul Mohan</dc:creator>
      <pubDate>Thu, 23 Jun 2022 07:21:29 +0000</pubDate>
      <link>https://dev.to/mehulmpt/gift-a-thon-by-codedamn-1i6j</link>
      <guid>https://dev.to/mehulmpt/gift-a-thon-by-codedamn-1i6j</guid>
      <description>&lt;p&gt;Every month, we at &lt;strong&gt;codedamn&lt;/strong&gt; come up with new events to keep your brain cells engaged over the weekend. What’s unique about this one?&lt;/p&gt;

&lt;h2&gt;What is Gift-a-thon?&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Gift-a-thon&lt;/strong&gt; is a 2-day long initiative of learning and sharing. On the 24th of June, we’ll be rolling out a feature that will allow you to get licenses to &lt;strong&gt;Learning Paths&lt;/strong&gt; and &lt;strong&gt;Pro Subscriptions&lt;/strong&gt; for your buddies at discounted prices. &lt;/p&gt;

&lt;p&gt;Only for the launch weekend commencing soon, you’ll be able to grab these vouchers at heavily slashed rates and we are low-key excited about it!&lt;/p&gt;

&lt;h2&gt;Why should you get licenses for your friends?&lt;/h2&gt;

&lt;p&gt;Because mugs are outdated! We are tired of watching people buy expensive diaries &amp;amp; pens their friends have enough of. We are also tired of listening to people complain about not finding the right opportunities, resources, or projects to work on. &lt;/p&gt;

&lt;p&gt;We came up with the idea of letting you &lt;strong&gt;share the gift of knowledge&lt;/strong&gt;! Simply hand over a &lt;strong&gt;redemption code&lt;/strong&gt; to our platform to anyone you fancy, which can be &lt;strong&gt;activated at any time&lt;/strong&gt; in the future and your friends are set! &lt;/p&gt;

&lt;p&gt;Plus, you can actively collaborate with your friends on &lt;strong&gt;codedamn Playgrounds &lt;/strong&gt;while you learn! Read more about &lt;a href="https://codedamn.com/news/product/how-to-use-codedamn-playgrounds"&gt;Collaboration on Playgrounds here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;How do you participate?&lt;/h2&gt;

&lt;p&gt;If you’re interested in being a part of &lt;strong&gt;Gift-a-thon&lt;/strong&gt;, simply head over to &lt;a href="https://codedamn.com/gift-a-thon"&gt;this page&lt;/a&gt; and fill out your details so we can send you a notification when we go live. &lt;/p&gt;

&lt;p&gt;We have &lt;strong&gt;limited licenses&lt;/strong&gt; available at the slashed rates so make sure you’re quick to grab your codes. &lt;/p&gt;

&lt;p&gt;Once the clock strikes midnight on the 24th of June, head over to the same link and add as many licenses to your cart as you’d need. Keep your job-hungry friends in mind when you do so in order to get a higher discount and that’s pretty much it. &lt;strong&gt;For every license that you add to your cart, you’ll unlock an additional discount&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;How does redemption work?&lt;/h2&gt;

&lt;p&gt;If you grab 10 licenses, you will get your hands on 10 unique codes. These codes can be redeemed on the same link used to get the codes. &lt;/p&gt;

&lt;p&gt;Note that every code can be used only once, and can be used only on a valid &lt;strong&gt;codedamn&lt;/strong&gt; account.&lt;/p&gt;

&lt;h2&gt;Can you gift a code to yourself?&lt;/h2&gt;

&lt;p&gt;You can, however, codes cannot be used to &lt;strong&gt;extend&lt;/strong&gt; your existing subscription. If you’re already a &lt;strong&gt;Pro Subscriber&lt;/strong&gt; (and we are really glad you are), you will not be able to redeem the voucher code for your account.&lt;/p&gt;

&lt;p&gt;With that being said, if you already have access to a specific &lt;strong&gt;Learning Path&lt;/strong&gt;, you can always get vouchers for different domains.&lt;/p&gt;

&lt;h2&gt;Ending Notes&lt;/h2&gt;

&lt;p&gt;We are super excited to have you invite your friends to our platform. We are sure they’ll love &lt;strong&gt;codedamn&lt;/strong&gt; just as much as you do! In case of any doubts or queries, as usual, shoot an email to &lt;a href="mailto:support@codedamn.com"&gt;support@codedamn.com&lt;/a&gt; and we’d be more than happy to help you out! &lt;/p&gt;

&lt;p&gt;While you wait for &lt;a href="https://codedamn.com/gift-a-thon"&gt;Gift-a-thon&lt;/a&gt; to unfold, &lt;a href="https://codedamn.com/learning-paths"&gt;learn to code like it’s 2030 with us&lt;/a&gt;!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How much JavaScript to learn before learning React?</title>
      <dc:creator>Mehul Mohan</dc:creator>
      <pubDate>Mon, 28 Jun 2021 19:09:30 +0000</pubDate>
      <link>https://dev.to/mehulmpt/how-much-javascript-to-learn-before-learning-react-1b51</link>
      <guid>https://dev.to/mehulmpt/how-much-javascript-to-learn-before-learning-react-1b51</guid>
      <description>&lt;p&gt;How much JS should I know before I start learning React - this is a very common question I get asked all the time. In this blog post, I will breakdown a few myths and also list some very important topics/things you should know before you start React, or any other similar library/framework (Angular, Vue, etc.)&lt;/p&gt;

&lt;h2&gt;
  
  
  You don't need to learn all of JavaScript
&lt;/h2&gt;

&lt;p&gt;Stress on the keyword "all". A very important thing is that if your aim is to become, say a frontend developer (&lt;a href="https://codedamn.com/news/become-a-frontend-developer"&gt;a complete guide on it here&lt;/a&gt;), you don't want to spend month after month on only JavaScript preparation.&lt;/p&gt;

&lt;p&gt;The ideal mix that worked for me is to learn "just enough" to move on to React. This absolutely does not mean that you have learned JavaScript. This only means that you don't need to. JavaScript, like any programming language, can be vast, especially with all the tooling and ecosystem around it. Therefore, it is super important to get the core, fundamental understanding of JavaScript ready before you learn anything that involves JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Should I learn React directly without JavaScript?
&lt;/h2&gt;

&lt;p&gt;Different people might give different answers here. Don't get tricked by only one opinion (applies to this blog post too). In my opinion, the fastest way to learn and absorb React is to go through JavaScript, and not directly jumping on React.&lt;/p&gt;

&lt;p&gt;The reason for this is context switching. When you learn React, you will parallelly learn a lot of JavaScript too, all the time. If you come with a solid understanding of JavaScript to React, you will spend a lot of time in React methodologies and how to work inside a React codebase, best practices and libraries to choose. This is only possible if you aren't asking every minor detail about JavaScript syntax/code. If you do too much context switching from React to JavaScript learning, you'll eventually make less progress on both ends.&lt;/p&gt;

&lt;p&gt;However this also does not mean that you should over optimize your JavaScript learnings for React. You don't need to, for example, learn about Node.js or streams in Node.js to become a good React developer. You also don't need to learn about service workers and ES6 proxies for becoming a good React developer. A typical coding course might confuse you that you need those parts, but trust me, initially you don't. You can always "context switch" and come back to learn these things if needed.&lt;/p&gt;

&lt;p&gt;Okay, so if this is not required, then what is truly required before you move on to React?&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to learn before learning React
&lt;/h2&gt;

&lt;p&gt;Here's a compiled list of topics I believe you should know. I have divided these topics into 3 categories: Diamond, Gold, Silver.&lt;/p&gt;

&lt;p&gt;Diamond topics - absolutely mandatory and you should have a crystal clear solid understanding. They will haunt you back if you try to skip these.&lt;/p&gt;

&lt;p&gt;Gold - recommended to learn, but you can do some context switching and learn them on the "runtime"&lt;/p&gt;

&lt;p&gt;Silver - these might be advanced topics that are good to know under the hood things, but usually not needed in initial phase.&lt;/p&gt;

&lt;p&gt;Diamond topics are super important. I often think of this quote when people ask me can we start directly with React and learn JS later:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It isn't the mountains ahead to climb that wear you out; it's the pebble in your shoe.- Muhammad Ali&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Diamond pre-requisites for React
&lt;/h3&gt;

&lt;p&gt;The points below are few things you can almost not afford to miss. If you have a weak understanding on these topics, they'll become bigger bottlenecks in your journey as and when you move ahead.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Using a computer, a browser.&lt;/li&gt;
&lt;li&gt;  Language syntax.&lt;/li&gt;
&lt;li&gt;  Programming fundamentals - variables, functions, loops, conditionals, how a program runs.&lt;/li&gt;
&lt;li&gt;  Working with a text editor like VSCode.&lt;/li&gt;
&lt;li&gt;  Understanding of HTML, CSS and how it connects to JavaScript with DOM API.&lt;/li&gt;
&lt;li&gt;  Basic operations with JavaScript - network requests, alerts, DOM changes, event listeners&lt;/li&gt;
&lt;li&gt;  Asynchronous behavior of JavaScript - Callbacks, promises, async/await.&lt;/li&gt;
&lt;li&gt;  Data structures and data types in JavaScript and how they differ from each other - string, boolean, undefined, null, objects, etc.&lt;/li&gt;
&lt;li&gt;  Ability to write simple standalone JS programs and functions (like calculating prime numbers, making 10 HTTP requests sequentially/parallelly using loops/promises, etc.)&lt;/li&gt;
&lt;li&gt;  Ability to google your problems, always.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have any additions to it, feel free to leave them in a comment below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gold pre-requisites for React
&lt;/h3&gt;

&lt;p&gt;These things are not strictly required, but are recommended in order to create an even stronger steel framework of understanding.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  ES6+ syntax - how ES6 module system works, why &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; were introduced, variable scoping concepts, function hoisting.&lt;/li&gt;
&lt;li&gt;  Linux command line - How to work with bash commands, creating folders, running scripts, deleting files, navigating around filesystem.&lt;/li&gt;
&lt;li&gt;  Git - How to deploy your projects to remote websites like GitHub using git from your command line.&lt;/li&gt;
&lt;li&gt;  Package manager understanding - how npm or yarn work, why are they even required, semantic versioning, lockfiles.&lt;/li&gt;
&lt;li&gt;  High level overview of additional tooling - webpack, babel, prettier, vscode.&lt;/li&gt;
&lt;li&gt;  Hosting providers you can use to deploy your static sites easily - netlify, vercel, github pages, heroku, etc.&lt;/li&gt;
&lt;li&gt;  Browser devtools like chrome devtools for debugging your code/errors or inspecting network requests.&lt;/li&gt;
&lt;li&gt;  Understanding about JSON/APIs/HTTP/REST practices in a little depth.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Silver pre-requisites for React
&lt;/h3&gt;

&lt;p&gt;These things are not required initially, but can really help you in long run becoming a great developer overall with your stack. In a nutshell, this section can come "after" learning React too.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  TypeScript with React - how to strongly type your code to catch more errors at development time&lt;/li&gt;
&lt;li&gt;  A clear structure of organizing your files/folders in a project.&lt;/li&gt;
&lt;li&gt;  CI/CD knowledge, for example, with GitHub actions for deploying new changes automatically.&lt;/li&gt;
&lt;li&gt;  Code testing to ship code confidently to production.&lt;/li&gt;
&lt;li&gt;  Stronger grip on best libraries in the ecosystem for their specific use case ( &lt;code&gt;react-query&lt;/code&gt;? &lt;code&gt;apollo-graphql&lt;/code&gt;? &lt;code&gt;tailwindcss&lt;/code&gt;? &lt;code&gt;next&lt;/code&gt;?)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  codedamn's frontend learning path
&lt;/h2&gt;

&lt;p&gt;The sad state of web development right now is that there's not a lot that needs to be learnt to become a great developer, but the content noise levels are all time high. The secret is to just a few things in depth.&lt;/p&gt;

&lt;p&gt;If you're looking to learn frontend web development, my personal recommendation is to research for any &lt;strong&gt;one&lt;/strong&gt; good complete source where you can learn from start to end, instead of being half pregnant on nine websites teaching you different things differently. We also provide a full blown &lt;a href="https://codedamn.com/learning-paths/fullstack"&gt;full-stack learning path roadmap&lt;/a&gt;, that covers frontend as close to 50% of the curriculum. Feel free to try it.&lt;/p&gt;

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

&lt;p&gt;This blog post should have given you a clarity on how much JavaScript you should be aware of before starting learning React. How to learn React properly? That's for another blog post. If the article helped you, feel free to subscribe to the developer newsletter below to receive weekly updates on more high quality articles here.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>The complete guide to becoming a frontend web developer in 2021</title>
      <dc:creator>Mehul Mohan</dc:creator>
      <pubDate>Sat, 26 Jun 2021 14:18:17 +0000</pubDate>
      <link>https://dev.to/mehulmpt/the-complete-guide-to-becoming-a-frontend-web-developer-in-2021-4cj</link>
      <guid>https://dev.to/mehulmpt/the-complete-guide-to-becoming-a-frontend-web-developer-in-2021-4cj</guid>
      <description>&lt;p&gt;Today, it is clear that web development is a great skill to have. In this blog post, let us look at what do you need to do exactly to become a frontend web developer in 2021 and beyond.&lt;/p&gt;

&lt;h1&gt;
  
  
  The problem
&lt;/h1&gt;

&lt;p&gt;The problem with the web right now is the information overload and noise. jQuery, Angular, Ember, Vue, React, Next.js, Nuxt.js, TypeScript, Sass, Webpack, NPM, Yarn, ESbuild, snowpack, ...! There are so many things, so many tools, so much you can learn - that often it becomes discouraging to even start.&lt;/p&gt;

&lt;p&gt;Then there's the point of what is relevant today, what will be relevant 3 years from now, etc. Let us clarify a few things in this blog:&lt;/p&gt;

&lt;h2&gt;
  
  
  You don't need to learn everything
&lt;/h2&gt;

&lt;p&gt;A common misconception is that you need to learn everything to be a great developer. This is completely false.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to own a "complete" tech stack. A complete tech stack is a stack using which you can create almost any project you'd like.&lt;/li&gt;
&lt;li&gt;You need to be aware of most, if not all popular tools in the ecosystem. Note, this does not mean you need to know how to work with them. But you should know they exist.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  You need to bet on a stack
&lt;/h2&gt;

&lt;p&gt;Angular vs React vs Vue vs Svelte vs xyz. This discussion will never end. The truth is, every single popular framework/library out there is popular because people use it and they're good at what they do.&lt;/p&gt;

&lt;p&gt;You can try spending time with different technologies if you'd like. But my personal recommendation is not to switch major libraries/frameworks every month or two.&lt;/p&gt;

&lt;p&gt;Sure, you can switch from React to Angular watching a 4 hour course. However remember that there's a certain mental model you need to develop when you're working with a technology, and that could take weeks if not months to get comfortable with.&lt;/p&gt;

&lt;p&gt;Do not switch to the hottest technology in the market, stick to a tech stack you work with.&lt;/p&gt;

&lt;h1&gt;
  
  
  The framework to learn frontend web development in 2021
&lt;/h1&gt;

&lt;p&gt;Alright. Now the big question. What do you actually learn from all the noise in the world. Let's split the question in two parts - (What and How) to learn frontend web development. Both are equally important questions as you can save or waste a lot of time depending on the decision you take. Let's start.&lt;/p&gt;

&lt;h1&gt;
  
  
  What to learn for frontend web development?
&lt;/h1&gt;

&lt;p&gt;This is a no bs list of things you should learn for frontend web development. Please note that this would be opinionated because my experience is heavily with these technologies (the platform you're reading this on, codedamn, has been built with all of these technologies)&lt;/p&gt;

&lt;h2&gt;
  
  
  Internet fundamentals
&lt;/h2&gt;

&lt;p&gt;This might come as a surprise to many. Most sites will recommend starting with HTML/CSS, but I feel even before that, you should understand how the internet and web works on a high level. What are HTML documents, how they're sent from a backend server, what is DNS, what exactly happens when you type google.com in the browser, etc.&lt;/p&gt;

&lt;p&gt;Of course, you should not need to go in depth of any of the topics, but it provides a very solid understanding of things when you're suddenly using dev-servers for development, slightly start shifting to backend, or try to debug network requests later in your journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML5/CSS3
&lt;/h2&gt;

&lt;p&gt;HTML and CSS are the fundamental building blocks of web. There's no doubt that this should be the first thing you should learn as a frontend developer.&lt;/p&gt;

&lt;p&gt;Some very important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you learn about modern HTML5 syntax&lt;/li&gt;
&lt;li&gt;Try to learn about semantic tags in HTML5 instead of sticking everything inside divs&lt;/li&gt;
&lt;li&gt;Learn about modern layout practices in CSS (flexbox, grid)&lt;/li&gt;
&lt;li&gt;Learn about modern CSS syntax and have a clarity on selectors, media queries, properties, values, etc. - the fundamentals.&lt;/li&gt;
&lt;li&gt;Do not stick with older and deprecated syntax ( center tag, marquee, etc.)&lt;/li&gt;
&lt;li&gt;Do not spend a lot of time learning about old layout practices in CSS with floats, etc.&lt;/li&gt;
&lt;li&gt;Do not try every cutting edge CSS3/4 feature. A lot of them might not be supported in browsers yet. Stick to the widely supported CSS3 features at most.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript is super important for interactivity and anything you do beyond a simple static HTML/CSS landing page. It can be used extensively beyond frontend too (in Node.js/Deno/TypeScript) therefore it is essential you get your fundamentals right with JavaScript.&lt;/p&gt;

&lt;p&gt;Some very important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you learn about ES6+ syntax. Do not use var and even follow tutorials using them. They're not needed in most cases. One way to check that is to try following tutorials done after 2017.&lt;/li&gt;
&lt;li&gt;JavaScript has some behaviors that might catch you off guard. For example, why 0.1 + 0.2 is not 0.3, or why null == undefined is true in JS. Remember, there are always reasons for these behaviors. You're a google search away to understand such things.&lt;/li&gt;
&lt;li&gt;JavaScript is fundamentally an asynchronous and non-blocking I/O language. This means you should understand how some core parts of asynchronous things like Promises work in JavaScript.
Learn about DOM API and understand it's an API provided by your browser to your JS code to interact with your HTML/CSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Developer Tools
&lt;/h2&gt;

&lt;p&gt;At this time, you should also start exploring how to work with devtools of your browser. I prefer Chrome devtools because they're great for debugging and working with JavaScript and DOM. Irrespective of your choice, I would prefer building projects and debugging any issues you face using devtools, instead of staring at your code for hours.&lt;/p&gt;

&lt;p&gt;Chrome devtools, just like any other tool in real life or a virtual product, would require a little training and you'll have to spend some time to be maximum efficient with it. However, the time you spend learning browser devtool will pay for itself in orders of magnitude as your developer life goes on.&lt;/p&gt;

&lt;p&gt;Some important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I recommend sticking to Chrome devtools because they're super powerful.&lt;/li&gt;
&lt;li&gt;Learn about DOM manipulation, debugging network requests, setting breakpoints on events, jumping through sources, searching for code in your website assets, throttling network speed, and more.&lt;/li&gt;
&lt;li&gt;This will be an ongoing learning, just like all other technologies. You should not aim to learn devtools at once, simply learn small but important things and move on. You will learn a lot more as you're working with projects, etc.
Git&lt;/li&gt;
&lt;li&gt;You need to learn a Version Control System (VCS), and it should be git. Git is a widely used VCS used by teams and companies to manage their codebases across employees. Git can be super complex to learn, but initially your use case of learning git would be to get your code deployed on GitHub, or a similar site.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is required because when you learn git, you can push to github. When you are able to push to github, you can integrate with many services like GitHub pages, Vercel, Netlify, etc. to create a live preview of your website/project. This live preview then can be shared with your friends, family and even added on your resumes.&lt;/p&gt;

&lt;p&gt;As you get employed, or work with a team of 2+ developers, you'll need git knowledge anyway. But even as a solo developer, it is of utmost importance as it makes your deployment cycle to a live website a breeze.&lt;/p&gt;

&lt;p&gt;Some important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git can get complex super quick. Do not get confused with a lot of git commands. As a solo developer, you'll hardly need anything beyond 5-7 commonly used commands.&lt;/li&gt;
&lt;li&gt;While point 1 is true, you should still understand the overall architecture of how git works, what branches are, what does one mean by remote repositories, etc. This is again, a solid framework of understanding that you should have.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  NPM/Yarn
&lt;/h2&gt;

&lt;p&gt;NPM and Yarn are two most popular package managers for JavaScript. They both exist for the same purpose - managing dependencies in your codebase. A dependency is a package/software usually not developed by you/your team, but you can still use and integrate it inside your app. For example, a design system like bootstrap or tailwind CSS is a dependency.&lt;/p&gt;

&lt;p&gt;If there's any update to the dependency, a bugfix or a security patch, the maintainer of the package updates it on the NPM repo, and you can update the package with your package manager. Alongside this, it also helps with a number of things you'll find out when you learn about NPM and yarn.&lt;/p&gt;

&lt;p&gt;Some important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NPM and yarn are very close concepts-wise. When you learn about npm, you'll also learn about package.json, lockfiles, why they're needed and more. All these things are transferrable to yarn v1 as package manager too.&lt;/li&gt;
&lt;li&gt;Therefore, do not stress a lot about what package manager you should learn. Learn any one (like yarn), and you can automatically switch to another if your project requires.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;At codedamn, we bet heavily on React. Not because we feel like it is superior to others, but this is us following our own advice given in the top of the article - stick to a tech stack.&lt;/p&gt;

&lt;p&gt;I worked with Angular.js in the past (2015 time), switched to Angular 2 - didn't like it much, and then made the switch to React. Since then, I've been using React myself for almost any medium+ complexity frontend project.&lt;/p&gt;

&lt;p&gt;React is an amazing library with a tremendous community support. Any problem/bug you run in with React - chances are someone already did that mistake and asked a question on 1000 websites. Therefore, if you're a good googler, you should not face any problem working with React.&lt;/p&gt;

&lt;p&gt;Some important points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React looks simple on the surface, but it requires developing a mental model to work at scale. It's not only about concepts and hooks, it's also about how to architect your app, make it maintainable, choosing the right libraries for the ecosystem, etc.&lt;/li&gt;
&lt;li&gt;React does not enforce any standard practices for common tasks, like network requests or UI. But we recommend the following options - react-query for network requests, tailwind CSS or material UI for UI library.&lt;/li&gt;
&lt;li&gt;Do not learn in-depth about class based components unless you have to work on a legacy codebase that requires you to learn about them in depth. Class based components are not the future of React. Run away from tutorials that teach you class based components. Learn about functional components and hooks instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Module bundlers
&lt;/h2&gt;

&lt;p&gt;Webpack is one of the most popular module bundler that React uses out of the box right now. Again, you don't necessarily need to learn webpack in depth, but you should know about what webpack.config.js file is and what are the top 10 useful options in it, and what they can do.&lt;/p&gt;

&lt;p&gt;ESBuild is also another relatively very very fast module bundler right now, but the plugin support for it isn't great yet. As a beginner, you don't need to worry about ESBuild yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Testing
&lt;/h2&gt;

&lt;p&gt;Last but not least, you should also focus on code testing. I feel people should start with end to end testing because it seems easier and more intuitive as a reason for code testing, compared to snapshot testing or unit testing.&lt;/p&gt;

&lt;p&gt;My recommended tool here is to use Cypress - which has a very friendly syntax to test your applications end to end i.e. your code will act like a user using your app and can pretty much perform any action your user can perform, but in an automated fashion saving your time and energy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice! Practice! Practice!
&lt;/h2&gt;

&lt;p&gt;One thing not explicitly mentioned in the blog post above is the fact that you need to practice a lot, all the time. Practice is the way to fit concepts in your brain. If you're only watching videos, you are not learning.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to learn frontend web development?
&lt;/h1&gt;

&lt;p&gt;The above list is not an exhaustive list of topics, but definitely a solid start as a guide. Now the question is how do you learn frontend web development? Here, I have two options for you:&lt;/p&gt;

&lt;h2&gt;
  
  
  You want a structured learning approach with support and practice modules
&lt;/h2&gt;

&lt;p&gt;The purpose of codedamn platform to exist is to solve this structuring, support and practice. We have a full &lt;a href="https://codedamn.com/learning-paths/frontend"&gt;Frontend Web Developer curriculum&lt;/a&gt; of 50+ hours with over 60+ practice sessions including the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Practice projects built in
Interactive learning (completing labs and challenges inside browser)&lt;/li&gt;
&lt;li&gt;Video lectures by top industry experts&lt;/li&gt;
&lt;li&gt;We always keep this curriculum up to date with industry standards with all the things mentioned in the blog post above, and some more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  You want a free learning approach
&lt;/h2&gt;

&lt;p&gt;If you cannot afford codedamn's learning path above with money, you can spend your time on free resources instead. Irrespective of that, using these resources with codedamn learning path is also recommended.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use google, a lot, for learning and doubt clarification.
Watch YouTube videos, but make sure they're relatively new, especially with topics like JavaScript and React.&lt;/li&gt;
&lt;li&gt;Practice on your own, build projects and deploy them online for people to see.&lt;/li&gt;
&lt;li&gt;Take up free courses on codedamn (we have a lot of 100% free courses too), like this react query course.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Time is money, in fact, sometimes more important than money. &lt;/p&gt;

&lt;p&gt;What you want to spend (or can spend), is upto you. But I'd recommend that even if not codedamn, spending money on your education to get an acceleration and clarity on what you're trying to achieve would definitely be worth it.&lt;/p&gt;

&lt;p&gt;The average salary of a frontend developer is $100,000/year. In fact, a codedamn yearly subscription would pay for itself, probably in the first 10 days of your job as a frontend developer.&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Web Scraping Python Tutorial – How to Scrape Data From A Website</title>
      <dc:creator>Mehul Mohan</dc:creator>
      <pubDate>Fri, 25 Sep 2020 22:20:05 +0000</pubDate>
      <link>https://dev.to/mehulmpt/web-scraping-python-tutorial-how-to-scrape-data-from-a-website-kic</link>
      <guid>https://dev.to/mehulmpt/web-scraping-python-tutorial-how-to-scrape-data-from-a-website-kic</guid>
      <description>&lt;p&gt;Python is a beautiful language to code in. It has a great package ecosystem, there's much less noise than you'll find in other languages, and it is super easy to use.&lt;/p&gt;

&lt;p&gt;Python is used for a number of things, from data analysis to server programming. And one exciting use-case of Python is Web Scraping.&lt;/p&gt;

&lt;p&gt;In this article, we will cover how to use Python for web scraping. We'll also work through a complete hands-on classroom guide as we proceed.&lt;/p&gt;

&lt;p&gt;Note: We will be scraping a webpage that I host, so we can safely learn scraping on it. Many companies do not allow scraping on their websites, so this is a good way to learn. Just make sure to check before you scrape.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction to Web Scraping classroom
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8fpLcrVZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b586debf09zukxh0ik07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8fpLcrVZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b586debf09zukxh0ik07.png" alt="Classroom demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to code along, you can use this &lt;a href="https://codedamn.com/practice/web-scraping-python-beautifulsoup"&gt;free codedamn classroom&lt;/a&gt; that consists of multiple labs to help you learn web scraping. This will be a practical hands-on learning exercise on codedamn, similar to how you learn on freeCodeCamp.&lt;/p&gt;

&lt;p&gt;In this classroom, you'll be using this page to test web scraping: &lt;a href="https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&gt;https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This classroom consists of 7 labs, and you'll solve a lab in each part of this blog post. We will be using Python 3.8 + BeautifulSoup 4 for web scraping.&lt;/p&gt;

&lt;h1&gt;
  
  
  Part 1: Loading Web Pages with 'request'
&lt;/h1&gt;

&lt;p&gt;This is the &lt;a href="https://codedamn.com/practice/web-scraping-python-beautifulsoup/a674e637-d958-4527-8930-cc53d1fb68e9"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The requests module allows you to send HTTP requests using Python.&lt;/p&gt;

&lt;p&gt;The HTTP request returns a Response Object with all the response data (content, encoding, status, and so on). One example of getting the HTML of a page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'https://codedamn.com'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Passing requirements:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Get the contents of the following URL using requests module: &lt;a href="https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&gt;https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Store the text response (as shown above) in a variable called txt&lt;/li&gt;
&lt;li&gt;Store the status code (as shown above) in a variable called status&lt;/li&gt;
&lt;li&gt;Print txt and status using print function&lt;/li&gt;
&lt;li&gt;Once you understand what is happening in the code above, it is fairly simple to pass this lab. Here's the solution to this lab:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="c1"&gt;# Make a request to https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/
# Store the result in 'res' variable
&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;'https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# print the result
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's move on to part 2 now where you'll build more on top of your existing code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: Extracting title with BeautifulSoup
&lt;/h2&gt;

&lt;p&gt;This is the &lt;a href="https://codedamn.com/practice/web-scraping-python-beautifulsoup/e55282e8-8481-4fb9-9a95-5df4d4a526ce"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this whole classroom, you’ll be using a library called BeautifulSoup in Python to do web scraping. Some features that make BeautifulSoup a powerful solution are:&lt;/p&gt;

&lt;p&gt;It provides a lot of simple methods and Pythonic idioms for navigating, searching, and modifying a DOM tree. It doesn't take much code to write an application&lt;br&gt;
Beautiful Soup sits on top of popular Python parsers like lxml and html5lib, allowing you to try out different parsing strategies or trade speed for flexibility.&lt;br&gt;
Basically, BeautifulSoup can parse anything on the web you give it.&lt;/p&gt;

&lt;p&gt;Here’s a simple example of BeautifulSoup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://codedamn.com"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="c1"&gt;# gets you the text of the &amp;lt;title&amp;gt;(...)&amp;lt;/title&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Passing requirements:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use the requests package to get title of the URL: &lt;a href="https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&gt;https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Use BeautifulSoup to store the title of this page into a variable called page_title&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Looking at the example above, you can see once we feed the page.content inside BeautifulSoup, you can start working with the parsed DOM tree in a very pythonic way. The solution for the lab would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="c1"&gt;# Make a request to https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Extract title of page
&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;

&lt;span class="c1"&gt;# print the result
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This was also a simple lab where we had to change the URL and print the page title. This code would pass the lab.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3: Soup-ed body and head
&lt;/h2&gt;

&lt;p&gt;This is the &lt;a href="https://codedamn.com/practice/web-scraping-python-beautifulsoup/a91108fd-2f13-4640-ac62-d7877235376a"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the last lab, you saw how you can extract the title from the page. It is equally easy to extract out certain sections too.&lt;/p&gt;

&lt;p&gt;You also saw that you have to call .text on these to get the string, but you can print them without calling .text too, and it will give you the full markup. Try to run the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn.com"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Extract title of page
&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;

&lt;span class="c1"&gt;# Extract body of page
&lt;/span&gt;&lt;span class="n"&gt;page_body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;

&lt;span class="c1"&gt;# Extract head of page
&lt;/span&gt;&lt;span class="n"&gt;page_head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;

&lt;span class="c1"&gt;# print the result
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page_head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's take a look at how you can extract out body and head sections from your pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing requirements:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Repeat the experiment with URL: &lt;a href="https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&gt;https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Store page title (without calling .text) of URL in page_title&lt;/li&gt;
&lt;li&gt;Store body content (without calling .text) of URL in page_body&lt;/li&gt;
&lt;li&gt;Store head content (without calling .text) of URL in page_head&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you try to print the &lt;code&gt;page_body&lt;/code&gt; or &lt;code&gt;page_head&lt;/code&gt; you'll see that those are printed as strings. But in reality, when you &lt;code&gt;print(type page_body)&lt;/code&gt; you'll see it is not a string but it works fine.&lt;/p&gt;

&lt;p&gt;The solution of this example would be simple, based on the code above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Extract title of page
&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;

&lt;span class="c1"&gt;# Extract body of page
&lt;/span&gt;&lt;span class="n"&gt;page_body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;

&lt;span class="c1"&gt;# Extract head of page
&lt;/span&gt;&lt;span class="n"&gt;page_head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;

&lt;span class="c1"&gt;# print the result
&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page_head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Part 4: select with BeautifulSoup
&lt;/h2&gt;

&lt;p&gt;This is the &lt;a href="https://codedamn.com/practice/web-scraping-python-beautifulsoup/0ee9fa0e-e7ac-4afa-ad8a-b4b3d16900ef"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now that you have explored some parts of BeautifulSoup, let's look at how you can select DOM elements with BeautifulSoup methods.&lt;/p&gt;

&lt;p&gt;Once you have the soup variable (like previous labs), you can work with &lt;code&gt;.select&lt;/code&gt; on it which is a CSS selector inside BeautifulSoup. That is, you can reach down the DOM tree just like how you will select elements with CSS. Let's look at an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Extract first &amp;lt;h1&amp;gt;(...)&amp;lt;/h1&amp;gt; text
&lt;/span&gt;&lt;span class="n"&gt;first_h1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'h1'&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="n"&gt;text&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.select&lt;/code&gt; returns a Python list of all the elements. This is why you selected only the first element here with the &lt;code&gt;[0]&lt;/code&gt; index.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing requirements:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a variable &lt;code&gt;all_h1_tags&lt;/code&gt;. Set it to empty list.&lt;/li&gt;
&lt;li&gt;Use .select to select all the h1 tags and store the text of those h1 inside all_h1_tags list.&lt;/li&gt;
&lt;li&gt;Create a variable seventh_p_text and store the text of the 7th p element (index 6) inside.
The solution for this lab is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create all_h1_tags as empty list
&lt;/span&gt;&lt;span class="n"&gt;all_h1_tags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# Set all_h1_tags to all h1 tags of the soup
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'h1'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;all_h1_tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create seventh_p_text and set it to 7th p element text of the page
&lt;/span&gt;&lt;span class="n"&gt;seventh_p_text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'p'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_h1_tags&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seventh_p_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's keep going.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 5: Top items being scraped right now
&lt;/h2&gt;

&lt;p&gt;This is the &lt;a href="https://codedamn.com/learn/web-scraping-python-beautifulsoup/0f404796-1b8f-491b-9b50-9e47893d2e47"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's go ahead and extract the top items scraped from the URL: &lt;a href="https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&gt;https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you open this page in a new tab, you’ll see some top items. In this lab, your task is to scrape out their names and store them in a list called &lt;code&gt;top_items&lt;/code&gt;. You will also extract out the reviews for these items as well.&lt;/p&gt;

&lt;p&gt;To pass this challenge, take care of the following things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;.select&lt;/code&gt; to extract the titles. (Hint: one selector for product titles could be &lt;code&gt;a.title&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;code&gt;.select&lt;/code&gt; to extract the review count label for those product titles. (Hint: one selector for reviews could be &lt;code&gt;div.ratings&lt;/code&gt;) Note: this is a complete label (i.e. &lt;code&gt;2 reviews&lt;/code&gt;) and not just a number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new dictionary in the format:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'Asus AsusPro Adv...   '&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
   &lt;span class="s"&gt;"review"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'2 reviews&lt;/span&gt;&lt;span class="se"&gt;\n\n\n&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&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;Note that you are using the strip method to remove any extra newlines/whitespaces you might have in the output. This is important to pass this lab.&lt;/li&gt;
&lt;li&gt;Append this dictionary in a list called &lt;code&gt;top_items&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Print this list at the end&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are quite a few tasks to be done in this challenge. Let's take a look at the solution first and understand what is happening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create top_items as empty list
&lt;/span&gt;&lt;span class="n"&gt;top_items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# Extract and store in top_items according to instructions on the left
&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'div.thumbnail'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;elem&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'h4 &amp;gt; a.title'&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="n"&gt;text&lt;/span&gt;
    &lt;span class="n"&gt;review_label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'div.ratings'&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="n"&gt;text&lt;/span&gt;
    &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="s"&gt;"review"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;review_label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;top_items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;top_items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note that this is only one of the solutions. You can attempt this in a different way too. In this solution:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First of all, you select all the div.thumbnail elements which give you a list of individual products&lt;/li&gt;
&lt;li&gt;Then you iterate over them&lt;/li&gt;
&lt;li&gt;Because select allows you to chain over itself, you can use select again to get the title.&lt;/li&gt;
&lt;li&gt;Note that because you're running inside a loop for &lt;code&gt;div.thumbnail&lt;/code&gt; already, the &lt;code&gt;h4 &amp;gt; a.title&lt;/code&gt; selector would only give you one result, inside a list. You select that list's &lt;code&gt;0th&lt;/code&gt; element and extract out the text.
Finally, you strip any extra whitespace and append it to your list.
Straightforward right?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Part 6: Extracting Links
&lt;/h2&gt;

&lt;p&gt;This is the &lt;a href="https://codedamn.com/learn/web-scraping-python-beautifulsoup/be9b007a-ff03-45d5-ad44-1adecdb21e2a"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So far you have seen how you can extract the text, or rather innerText of elements. Let's now see how you can extract attributes by extracting links from the page.&lt;/p&gt;

&lt;p&gt;Here’s an example of how to extract out all the image information from the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create top_items as empty list
&lt;/span&gt;&lt;span class="n"&gt;image_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# Extract and store in top_items according to instructions on the left
&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'img'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'src'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;alt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'alt'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;image_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"alt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this lab, your task is to extract the &lt;code&gt;href&lt;/code&gt; attribute of links with their text as well. Make sure of the following things:&lt;/p&gt;

&lt;p&gt;You have to create a list called all_links&lt;br&gt;
In this list, store all link dict information. It should be in the following format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="s"&gt;"href"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;link here&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;link text here&amp;gt;"&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 your text is stripped of any whitespace&lt;br&gt;
Make sure you check if your &lt;code&gt;.text&lt;/code&gt; is &lt;code&gt;None&lt;/code&gt; before you call &lt;code&gt;.strip()&lt;/code&gt; on it.&lt;br&gt;
Store all these dicts in the all_links&lt;br&gt;
Print this list at the end&lt;br&gt;
You are extracting the attribute values just like you extract values from a dict, using the get function. Let's take a look at the solution for this lab:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create top_items as empty list
&lt;/span&gt;&lt;span class="n"&gt;all_links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# Extract and store in top_items according to instructions on the left
&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ahref&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ahref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;

    &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ahref&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'href'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s"&gt;''&lt;/span&gt;
    &lt;span class="n"&gt;all_links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;"href"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_links&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here, you extract the &lt;code&gt;href&lt;/code&gt; attribute just like you did in the image case. The only thing you're doing is also checking if it is None. We want to set it to an empty string, otherwise, we want to strip the whitespace.&lt;/p&gt;

&lt;p&gt;Part 7: Generating CSV from data&lt;br&gt;
This is the &lt;a href="https://codedamn.com/learn/web-scraping-python-beautifulsoup/a10e33c1-7780-40bc-a541-adc632fab185"&gt;link to this lab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Finally, let's understand how you can generate CSV from a set of data. You will create a CSV with the following headings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Product Name&lt;/li&gt;
&lt;li&gt;Price&lt;/li&gt;
&lt;li&gt;Description&lt;/li&gt;
&lt;li&gt;Reviews&lt;/li&gt;
&lt;li&gt;Product Image&lt;/li&gt;
&lt;li&gt;These products are located in the div.thumbnail. The CSV boilerplate is given below:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;csv&lt;/span&gt;
&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;all_products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'div.thumbnail'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# TODO: Work
&lt;/span&gt;    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Work on product here"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;all_products&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="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products.csv'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;dict_writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DictWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dict_writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writeheader&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;dict_writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writerows&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You have to extract data from the website and generate this CSV for the three products.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing Requirements:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Product Name is the whitespace trimmed version of the name of the item (example - Asus AsusPro Adv..)&lt;/li&gt;
&lt;li&gt;Price is the whitespace trimmed but full price label of the product (example - $1101.83)&lt;/li&gt;
&lt;li&gt;The description is the whitespace trimmed version of the product description (example - Asus AsusPro Advanced BU401LA-FA271G Dark Grey, 14", Core i5-4210U, 4GB, 128GB SSD, Win7 Pro)&lt;/li&gt;
&lt;li&gt;Reviews are the whitespace trimmed version of the product (example - 7 reviews)&lt;/li&gt;
&lt;li&gt;Product image is the URL (src attribute) of the image for a product (example - /webscraper-python-codedamn-classroom-website/cart2.png)&lt;/li&gt;
&lt;li&gt;The name of the CSV file should be products.csv and should be stored in the same directory as your script.py file
Let's see the solution to this lab:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;csv&lt;/span&gt;
&lt;span class="c1"&gt;# Make a request
&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"https://codedamn-classrooms.github.io/webscraper-python-codedamn-classroom-website/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'html.parser'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Create top_items as empty list
&lt;/span&gt;&lt;span class="n"&gt;all_products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;# Extract and store in top_items according to instructions on the left
&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'div.thumbnail'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'h4 &amp;gt; a'&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="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'p.description'&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="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'h4.price'&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="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;reviews&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'div.ratings'&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="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'img'&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="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'src'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;all_products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"reviews"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;reviews&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;"image"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;


&lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;all_products&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="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'products.csv'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;dict_writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DictWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dict_writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writeheader&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;dict_writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writerows&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The for block is the most interesting here. You extract all the elements and attributes from what you've learned so far in all the labs.&lt;/p&gt;

&lt;p&gt;When you run this code, you end up with a nice CSV file. And that's about all the basics of web scraping with BeautifulSoup!&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I hope this interactive classroom from codedamn helped you understand the basics of web scraping with Python.&lt;/p&gt;

&lt;p&gt;If you liked this classroom and this blog, tell me about it on my twitter and Instagram. Would love to hear feedback!&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Create a URL Shortener Project using MongoDB + Node - but hands-on!</title>
      <dc:creator>Mehul Mohan</dc:creator>
      <pubDate>Fri, 18 Sep 2020 23:09:32 +0000</pubDate>
      <link>https://dev.to/mehulmpt/create-a-url-shortener-project-using-mongodb-node-but-hands-on-1ai2</link>
      <guid>https://dev.to/mehulmpt/create-a-url-shortener-project-using-mongodb-node-but-hands-on-1ai2</guid>
      <description>&lt;p&gt;Let us learn about MongoDB, Mongoose, Node, and other tech by building a simple URL shortener project.&lt;/p&gt;

&lt;p&gt;Have you ever wondered how you could create a quick URL shortener for yourself? Like how twitter shortens your links when you share them? Or how bit.ly works?&lt;/p&gt;

&lt;p&gt;Sure enough, these are complicated companies, but the concept for URL shorteners is simple. Let's learn about MongoDB and other backend tools by actually building this project in 7 steps.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introduction to Project
&lt;/h1&gt;

&lt;p&gt;We will be using this &lt;a href="https://codedamn.com/practice/url-shortener-node"&gt;free URL shortener classroom&lt;/a&gt; from codedamn to really, like really create and evaluate our hands-on project and see the feedback.&lt;/p&gt;

&lt;p&gt;We will be using the following technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mongoose as the ORM&lt;/li&gt;
&lt;li&gt;MongoDB as the backend database&lt;/li&gt;
&lt;li&gt;Node.js as the backend&lt;/li&gt;
&lt;li&gt;A simple embedded JS file as the frontend&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Lab 1: Setting up the Express server
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5faV9K11--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/545m9ait9as8oih7alib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5faV9K11--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/545m9ait9as8oih7alib.png" alt="Lab 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The link of this &lt;a href="https://codedamn.com/practice/url-shortener-node/36280bc2-36b5-4f4e-8976-ed4687dc7cbd"&gt;lab is here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a fairly straightforward lab. We have to just create a route &lt;code&gt;/short&lt;/code&gt; which should respond appropriately. This code would let us pass:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Initialize express server on PORT 1337&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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;express&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World! - from codedamn&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/short&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello from short&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_PORT&lt;/span&gt;&lt;span class="p"&gt;,&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server started&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Lab 2: Setting up our view engine
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kg12eMod--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tniqqbsh3euadrko2vla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kg12eMod--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tniqqbsh3euadrko2vla.png" alt="Lab 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The link of this &lt;a href="https://codedamn.com/practice/url-shortener-node/0eb7b0b0-473e-4a83-9589-8ea13467972f"&gt;lab is here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're using a single &lt;code&gt;.ejs&lt;/code&gt; file, so let's explore that a little. Again, a very simple lab because we just have to change the name of the variable. This should get us done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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;express&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;view engine&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="s1"&gt;ejs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;index&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;myVariable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;My name is John!&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_PORT&lt;/span&gt;&lt;span class="p"&gt;,&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server started&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Lab 3: Setting up MongoDB
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OJorGi6i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/17mk2gxzaxx3szye6o6q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OJorGi6i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/17mk2gxzaxx3szye6o6q.png" alt="Lab 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The link of this &lt;a href="https://codedamn.com/practice/url-shortener-node/523eaae7-27ff-47fe-bfdc-67a65dfd5711"&gt;lab is here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this lab, we'll connect to MongoDB correctly and insert a record, just &lt;em&gt;for the record&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the solution which should get us to the next lab:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/short&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;
    &lt;span class="c1"&gt;// insert the record in 'test' collection&lt;/span&gt;
    &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;insertOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;testCompleted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Setup your mongodb connection here&lt;/span&gt;
&lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongodb://localhost/codedamn&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;useNewUrlParser&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;useUnifiedTopology&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;open&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Wait for mongodb connection before server starts&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_PORT&lt;/span&gt;&lt;span class="p"&gt;,&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server started&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="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Lab 4: Setting up a Mongoose schema
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EY2ScsZO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8n5v6u7lgx13o7e814jk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EY2ScsZO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8n5v6u7lgx13o7e814jk.png" alt="Lab 4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The link of this &lt;a href="https://codedamn.com/practice/url-shortener-node/a64e6946-a6ea-4ba7-8357-fe000c61658c"&gt;lab is here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, we define a schema in the &lt;code&gt;models/url.js&lt;/code&gt; file for proper handling with Mongoose, and here's the code for that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;mongoose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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;mongoose&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;shortId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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;shortid&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;shortUrlSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;full&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;short&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;shortId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;generate&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;clicks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;default&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="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;mongoose&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ShortUrl&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;shortUrlSchema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Also, as part of the challenge, we update the &lt;code&gt;/short&lt;/code&gt; route now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/short&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// insert the record using the model&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ShortURL&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;full&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;record&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&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;h1&gt;
  
  
  Lab 5: Linking the frontend, backend, + MongoDB
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bgakdREn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gb866nzm8buec6s9nq8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bgakdREn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gb866nzm8buec6s9nq8e.png" alt="Lab 5"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is also a simple lab. We just have to update the route to extract the URL passed and store it in the database using our schema.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;urlencoded&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;extended&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/short&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// Grab the fullUrl parameter from the req.body&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fullUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&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="nx"&gt;fullUrl&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;URL requested: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fullUrl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// insert and wait for the record to be inserted using the model&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;ShortURL&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;full&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fullUrl&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;record&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Lab 6: Displaying short URLs on the frontend
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bwZLRGZe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lhi7puwkir2gwbi6e6qa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bwZLRGZe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lhi7puwkir2gwbi6e6qa.png" alt="Lab 6"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we display the URL set on our website using the &lt;code&gt;.ejs&lt;/code&gt; variables passed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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;allData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ShortURL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;index&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;shortUrls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allData&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;h1&gt;
  
  
  Lab 7: Making the redirection work
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HuDazIbk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jcoavfyy0dy3gracnphq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HuDazIbk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jcoavfyy0dy3gracnphq.png" alt="Lab 7"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Finally, we link up the redirection scheme using dynamic express routes and correct status codes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/:shortid&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="c1"&gt;// grab the :shortid param&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shortid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&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="nx"&gt;shortid&lt;/span&gt;

    &lt;span class="c1"&gt;// perform the mongoose call to find the long URL&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;ShortURL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;short&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;shortid&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c1"&gt;// if null, set status to 404 (res.sendStatus(404))&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// if not null, increment the click count in database&lt;/span&gt;
    &lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clicks&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;// redirect the user to original link&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;full&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;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;And we can call it a day! You just built a fully working URL shortener by yourself using Express + Node + MongoDB. Give yourself a pat on back!&lt;/p&gt;

&lt;p&gt;The final source code is available on &lt;a href="https://github.com/codedamn-classrooms/node-mongodb-url-shortner/tree/lab7-sol"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have any feedback on this article or codedamn classrooms, feel free to reach out to me on Twitter. Let's discuss :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>node</category>
    </item>
  </channel>
</rss>
