<?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: Adesola Adeoluwa</title>
    <description>The latest articles on DEV Community by Adesola Adeoluwa (@sudodeo).</description>
    <link>https://dev.to/sudodeo</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%2F932354%2F17a9d371-a072-4318-b4a0-da13ea4fffce.jpeg</url>
      <title>DEV Community: Adesola Adeoluwa</title>
      <link>https://dev.to/sudodeo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sudodeo"/>
    <language>en</language>
    <item>
      <title>DIVING INTO THE NODE.JS EVENT LOOP AND CONCURRENCY MODEL</title>
      <dc:creator>Adesola Adeoluwa</dc:creator>
      <pubDate>Sat, 20 Jan 2024 05:54:29 +0000</pubDate>
      <link>https://dev.to/sudodeo/diving-into-the-nodejs-event-loop-and-concurrency-model-3d9h</link>
      <guid>https://dev.to/sudodeo/diving-into-the-nodejs-event-loop-and-concurrency-model-3d9h</guid>
      <description>&lt;p&gt;Welcome, amazing developers! Today, we're embarking on a voyage into the intricate waters of Node.js, uncovering the secrets of its event loop and concurrency model. Brace yourselves for a technical deep dive where JavaScript is your sturdy diving suit, and Node.js reveals a world of asynchronous wonders and non-blocking currents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Event Loop: The Pulsating Heart of Asynchronous Operations
&lt;/h2&gt;

&lt;p&gt;Think of the event loop as the beating heart of Node.js, tirelessly managing asynchronous tasks. Imagine your code as a series of tasks waiting to be executed, and the event loop orchestrating the order of play. It ensures that no task monopolizes the stage, allowing other operations to share the limelight.&lt;/p&gt;

&lt;p&gt;Consider a scenario where you're processing data from a file while handling user requests. The event loop juggles these tasks seamlessly, ensuring your application remains responsive. It's like a multitasking wizard, keeping the JavaScript party alive without missing a beat.&lt;/p&gt;

&lt;h2&gt;
  
  
  Non-Blocking I/O: Streamlining Operations Like a High-Tech Conveyor Belt
&lt;/h2&gt;

&lt;p&gt;Node.js embraces non-blocking I/O, transforming your code into a high-tech assembly line. Imagine each I/O operation as a station on this conveyor belt. You initiate an operation, receive a callback when it's done, and move on to the next task without waiting for the entire process to complete.&lt;/p&gt;

&lt;p&gt;Think of it as ordering items online. While waiting for your package to arrive, you don't halt all other activities. Node.js similarly allows your code to remain productive, handling multiple I/O operations concurrently. It’s like having a super-efficient butler that ensures your to-do list gets tackled promptly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Event-Driven Programming: The Code Party Planner
&lt;/h2&gt;

&lt;p&gt;Events are the lifeblood of Node.js, turning your code into a vibrant celebration. Imagine events as invitations and callbacks as responses to these invites. When an event occurs, the associated callback function gets executed – your code's way of saying, "I'm ready for the party!"&lt;/p&gt;

&lt;p&gt;Picture planning a surprise birthday bash in code. You send out invitations (register callbacks), and when the big day arrives (event triggered), the attendees (callbacks) bring the celebration to life. Event-driven programming adds a dynamic flair to your code, making it responsive and ready to rock any party.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concurrency Model: Sailing the Single-Threaded Seas with Worker Threads as First Mates
&lt;/h2&gt;

&lt;p&gt;Node.js sails the single-threaded seas, ensuring a clear and straightforward course. Picture your code as a sailor aboard this vessel, skillfully navigating through tasks without the complexity of multi-threading. But what happens when a storm of computation arises?&lt;/p&gt;

&lt;p&gt;Enter worker threads – your trusty first mates. When facing heavy computation, Node.js lets you delegate these tasks to worker threads while the main event loop steers the ship. Think of it as a well-coordinated pirate crew, each member handling their duties to keep the ship sailing smoothly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: Mastering the Depths of Node.js for Efficient JavaScript Development
&lt;/h2&gt;

&lt;p&gt;As you dive into the intricate mechanics of the Node.js event loop and concurrency model, you unveil the power of asynchronous operations and non-blocking paradigms. These concepts, akin to a well-choreographed dance, empower your JavaScript applications to handle numerous tasks concurrently, providing an efficient and responsive user experience.&lt;/p&gt;

&lt;p&gt;So, fellow developers, equip yourselves with the knowledge gained from this technical deep dive and continue your exploration of Node.js with confidence. The event loop and concurrency model are not just nautical metaphors; they are the tools that transform your code into a powerhouse of efficiency. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmnmjzyduqjdh71blh7q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmnmjzyduqjdh71blh7q.gif" alt="Goodbye" width="498" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>node</category>
      <category>eventloop</category>
    </item>
    <item>
      <title>Don't Be a Scrapegoat: Responsible Web Scraping in a Webbed World</title>
      <dc:creator>Adesola Adeoluwa</dc:creator>
      <pubDate>Thu, 11 Jan 2024 00:57:14 +0000</pubDate>
      <link>https://dev.to/sudodeo/dont-be-a-scrapegoat-responsible-web-scraping-in-a-webbed-world-40nn</link>
      <guid>https://dev.to/sudodeo/dont-be-a-scrapegoat-responsible-web-scraping-in-a-webbed-world-40nn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Web scraping, a powerful technique for extracting data from websites, opens up a realm of possibilities for developers. However, as we delve into this capability, it becomes crucial to approach it with a sense of responsibility, care and consideration.  In the words of Uncle Ben:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44w5i9e5n9gso0wv4l0l.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44w5i9e5n9gso0wv4l0l.gif" alt="spiderman gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Numerous tools and libraries (such as Python, Selenium, Octoparse) can aid in scraping a website, each with its own set of pros and cons. However, the focus of this article isn't on comparing them or how to use them; instead, we'll dive into the broader aspects of responsible web scraping.&lt;/p&gt;

&lt;p&gt;Let's embark on the journey of web scraping with a responsible mindset.&lt;/p&gt;
&lt;h2&gt;
  
  
  Common Ethical Concerns
&lt;/h2&gt;

&lt;p&gt;Now, let's talk about the ethical considerations surrounding the web scraping world. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data privacy&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ethical web scraping hinges on respecting user boundaries. Before extracting any data, especially personal information, prioritize obtaining explicit consent. Remember, privacy is a right, not a privilege.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Copyright Infringement&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tread carefully while scraping! Copyright laws guard web content, and unauthorized use can bite back. Respecting website owners' intellectual property rights is crucial. Seek permission or rely on fair use before "harvesting" their work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Terms of Service Violations&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every website has its own set of rules, like a digital clubhouse with a handbook. These "terms of service" dictate how you can play with their content. Unethical scraping is like breaking the clubhouse rules – you might get kicked out or even face legal trouble! To avoid any drama, always check the terms before you start scraping and play by the website's rules.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Legal Implications&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scraping with blinders on is a recipe for legal disaster. Privacy laws, copyright regulations, and even website rules act as guardrails – break them, and you risk fines, lawsuits, and public scorn. Navigate the legal landscape with care, ensuring your scraping stays within the boundaries of the law.&lt;/p&gt;

&lt;p&gt;We hold the keys to unlocking a future of ethical scraping! By tackling these concerns head-on, we, as developers, become architects of a tech landscape built on respect, transparency, and integrity. Let's rise to the challenge and make every scrape a step towards a responsible digital world.&lt;/p&gt;
&lt;h2&gt;
  
  
  Best Practices for Responsible Web Scraping
&lt;/h2&gt;

&lt;p&gt;Having discussed the ethical considerations, let's delve into best practices for responsible web scraping.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Respect Robots.txt&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More than just a simple "no trespassing" sign, the robots.txt file utilizes a specific language to guide crawlers. By learning its directives (like disallow or sitemap), you can navigate a website's content with precision and respect. Numerous online resources can equip you with this knowledge, turning robots.txt into a powerful communication tool, not a roadblock. To view the robots.txt file for any website, simply add &lt;code&gt;/robots.txt&lt;/code&gt; to the end of the base URL. For example, twitter's robots.txt file can be found at &lt;code&gt;https://twitter.com/robots.txt&lt;/code&gt;&lt;br&gt;
Below are some screenshots of robots.txt files from various websites:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmg1529wqys53d9xwmem.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmg1529wqys53d9xwmem.png" alt="dev.to robots.txt"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpoxzw91azjykhbp8nz68.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpoxzw91azjykhbp8nz68.png" alt="amazon.com robots.txt"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmrffsro78g8onh85nn3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhmrffsro78g8onh85nn3.png" alt="twitter.com robots.txt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Avoid Overloading Servers&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Imagine browsing your favorite website, only to encounter a laggy mess. That's what happens when bots bombard servers with requests. You don't want to bite the hand that feeds you. By practising rate limiting and responsible scraping, you become a champion for a smooth and seamless web experience for everyone. Twitter recommends a 1 second delay between concurrent requests as seen in the screenshot above.&lt;/p&gt;
&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;In the example below, the python code demonstrates unethical practices by scraping data without permission and violating the rules specified in the robots.txt file. Additionally, it sends an excessive number of requests, potentially causing server overload.&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="c1"&gt;# Unethically scraping data without permission
&lt;/span&gt;&lt;span class="n"&gt;response&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="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://unauthorized-website.com/private-data&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Ignoring robots.txt and sending excessive requests
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://target-website.com/sensitive-info&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



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

&lt;p&gt;Here's how you should do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt;

&lt;span class="c1"&gt;# Ethically scraping data with permission
&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;User-Agent&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;response&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="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://authorized-website.com/public-data&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Adhering to crawling politeness and spacing out requests
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;https://target-website.com/public-info&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;sleep&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="c1"&gt;# Introducing a delay between requests
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In summary, web scraping is a potent tool that requires responsible handling. By prioritizing ethical considerations, following best practices, and staying updated on legal implications, we play a part in fostering a positive and sustainable web scraping environment. Let's code with integrity, respecting the rights and privacy of others, and making sure our actions positively influence the digital landscape. Remember, great power demands great responsibility, so let's use it wisely.&lt;/p&gt;

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

</description>
    </item>
  </channel>
</rss>
