<?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>Forem: Apify</title>
    <description>The latest articles on Forem by Apify (@apifyblog).</description>
    <link>https://forem.com/apifyblog</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%2F1199146%2F25846ccf-9cfd-46a9-a3d0-0b947c365101.png</url>
      <title>Forem: Apify</title>
      <link>https://forem.com/apifyblog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/apifyblog"/>
    <language>en</language>
    <item>
      <title>Edge AI vs. Cloud AI</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Wed, 22 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/edge-ai-vs-cloud-ai-oak</link>
      <guid>https://forem.com/apify/edge-ai-vs-cloud-ai-oak</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hi, we're&lt;/strong&gt; &lt;a href="https://apify.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;, a cloud platform that helps you build reliable web scrapers fast and automate anything you can do manually in a web browser. This article on Edge AI vs. Cloud AI was inspired by our work on&lt;/strong&gt; &lt;a href="https://apify.it/data-for-ai" rel="noopener noreferrer"&gt;&lt;strong&gt;collecting data for AI and machine learning applications&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The rise of Edge AI&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Five years ago, Gartner predicted that &lt;a href="https://www.gartner.com/smarterwithgartner/what-edge-computing-means-for-infrastructure-and-operations-leaders" rel="noopener noreferrer"&gt;75% of enterprise data would be created and processed outside the cloud&lt;/a&gt; by 2025. Whether that will prove entirely accurate remains to be seen. But what is clear is that Edge AI is rapidly growing in popularity.&lt;/p&gt;

&lt;p&gt;The rise of edge computing accelerated in the 2010s with the explosion of IoT devices necessitating smarter, faster processing at the edge, in other words, closer to the data source. This gave rise to Edge AI, where AI algorithms are processed locally on a hardware device.&lt;/p&gt;

&lt;p&gt;The growing interest in Edge AI has generated a myth that edge computing will replace cloud computing. But in reality, Edge and Cloud can work hand-in-hand by synchronizing a decentralized edge and a centralized cloud.&lt;/p&gt;

&lt;p&gt;The purpose of this article isn't to tell you which of the two - Edge or Cloud - is better but to highlight the pros and cons of each so you can know which is suitable for your AI tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Edge AI?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Sometimes referred to as AI at the edge, Edge AI is the implementation of artificial intelligence in an edge computing environment. In other words, Edge AI allows computation to be done close to where data is collected rather than at an offsite data center. That means it processes data locally to provide swift response times due to on-device processing.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pros and cons of Edge AI&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Edge AI advantages&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reduced latency and bandwidth:&lt;/strong&gt; By processing data close to the edge, the need to transmit information over the network is reduced.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Swift response times:&lt;/strong&gt; Fully on-device processing provides quick services, which eliminates wait times due to remote server responses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Privacy and security:&lt;/strong&gt; Edge AI offers better security for personal data than transmitting it across networks, where it can be vulnerable to cyberattacks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Edge AI disadvantages&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Limited computing power:&lt;/strong&gt; Edge devices often have less computing power than cloud servers, limiting the complexity of AI models they can run.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost and scalability challenges:&lt;/strong&gt; Scaling Edge AI solutions across numerous devices can be complex and expensive due to the amount of money required to acquire, maintain, and operate computing resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintenance and upgrades:&lt;/strong&gt; Regular maintenance and updates of each edge device can be more challenging compared to centralized cloud updates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Machine variations:&lt;/strong&gt; There's more variation in machine types with edge devices, leading to more common failures.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa3sm2ye6qbfxpl3jq8yz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa3sm2ye6qbfxpl3jq8yz.jpg" alt="Cloud AI is where data processing and AI model execution occur in cloud-based servers." width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is Cloud AI?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Cloud AI refers to artificial intelligence systems where the data processing and AI model execution occur in cloud-based servers rather than on local devices.&lt;/p&gt;

&lt;p&gt;The foundation for Cloud AI was laid with the advent of cloud computing in the early noughties. The introduction of cloud AI services, such as Google's Cloud AI, AWS's SageMaker, and Microsoft's Azure AI, some ten years later, was a significant milestone. These platforms provided tools for machine learning, data analytics, and cognitive services (like &lt;a href="https://blog.apify.com/nlp-techniques/" rel="noopener noreferrer"&gt;natural language processing&lt;/a&gt; and &lt;a href="https://blog.apify.com/data-collection-for-computer-vision/" rel="noopener noreferrer"&gt;computer vision&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Because Cloud AI operates on data sent to remote servers, it's more scalable and flexible than Edge AI. That's the main thing that gives Cloud the edge (see what I did there?), but there are other advantages too:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pros and cons of Cloud AI&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cloud AI advantages&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Big data handling&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AI algorithms thrive on voluminous data for training and accuracy. Cloud storage is integral here, providing the capacity to store and process terabytes of data. This capability is essential for developing machine learning models that learn from vast, varied datasets to enhance their predictive accuracy and reliability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Parallel processing&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before cloud infrastructure, processing limitations were a significant bottleneck in AI development. Cloud computing introduced parallel processing nodes, which dramatically enhanced computing power. This means complex AI models can be computed much faster, accelerating the development and deployment of AI solutions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GPU acceleration&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Advanced AI computations, especially those in machine learning and deep learning, require significant processing power. GPUs, known for their &lt;a href="https://blog.apify.com/concurrency-vs-parallelism/" rel="noopener noreferrer"&gt;parallel processing&lt;/a&gt; capabilities, are ideal for these tasks. Cloud AI utilizes GPU acceleration to handle intensive AI computations efficiently.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scalability and flexibility&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the most significant advantages of cloud storage in AI is scalability. Cloud-based AI systems can adapt to varying computational demands, scaling up or down as needed. This flexibility allows for efficient management of resources and costs, which is particularly vital for fluctuating AI workloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cloud AI disadvantages&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Latency issues:&lt;/strong&gt; Depending on internet connectivity, there can be latency in data processing, which may not be suitable for real-time applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security concerns:&lt;/strong&gt; Transmitting data to and from cloud servers can pose security risks, especially if sensitive data is involved. That being said, cloud providers can provide strong security measures and compliance standards, so they can be a viable option if properly configured.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dependence on internet connectivity:&lt;/strong&gt; Cloud AI's effectiveness is contingent on reliable internet connectivity, which can be a limitation in remote or unstable network areas.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key takeaways: when to use Edge and when to use Cloud&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Edge computing&lt;/strong&gt; minimizes latency by processing data locally but has limitations in terms of computational resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cloud computing&lt;/strong&gt; provides powerful processing capabilities but introduces latency due to data transmission.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The choice&lt;/strong&gt; between Edge and Cloud depends on the latency tolerance of your application, the available network bandwidth, and the computational needs of your AI tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Edge AI&lt;/strong&gt; when real-time processing, data privacy, and reduced bandwidth usage are critical.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use Cloud AI&lt;/strong&gt; for complex computations, large-scale data analysis, and applications where latency is less of a concern.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Apify as a data cloud platform for AI&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If data in the cloud is what you need, Apify is a cloud platform that helps you &lt;a href="https://apify.com/web-scraping" rel="noopener noreferrer"&gt;build reliable web scrapers&lt;/a&gt; for real-time data collection, and automate anything you can do manually in a web browser. This makes it an ideal platform for extracting web data at scale for AI and machine learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🧑🏻💻&lt;/strong&gt; &lt;a href="https://apify.com/data-for-generative-ai" rel="noopener noreferrer"&gt;&lt;strong&gt;Web scraping for AI data&lt;/strong&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Apify excels in extracting vast amounts of data from the web, which is crucial for training and fine-tuning AI models like ChatGPT and LLaMA. Its ability to crawl and extract relevant information from various sources makes it a go-to solution for feeding AI algorithms.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🧩&lt;/strong&gt; &lt;a href="https://python.langchain.com/docs/integrations/tools/apify" rel="noopener noreferrer"&gt;&lt;strong&gt;Easy integration with AI tools&lt;/strong&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Apify facilitates the integration of scraped data into AI platforms. It supports the loading of data into &lt;a href="https://blog.apify.com/what-is-a-vector-database/" rel="noopener noreferrer"&gt;vector databases&lt;/a&gt; for querying to &lt;a href="https://blog.apify.com/how-to-ai-chatbot-python/" rel="noopener noreferrer"&gt;enhance the capabilities of AI chatbots&lt;/a&gt; and other applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;📈&lt;/strong&gt; &lt;a href="https://apify.com/enterprise" rel="noopener noreferrer"&gt;&lt;strong&gt;Customizable and scalable&lt;/strong&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Whether it's using &lt;a href="https://apify.com/store/categories/ai" rel="noopener noreferrer"&gt;pre-built scrapers&lt;/a&gt; or developing custom ones, Apify offers &lt;a href="https://apify.com/enterprise" rel="noopener noreferrer"&gt;tailored solutions&lt;/a&gt;. This flexibility is vital for AI applications that require specific, up-to-date data from diverse web sources.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://blog.apify.com/intercom-customer-support-ai-chatbot-web-scraping/" rel="noopener noreferrer"&gt;&lt;strong&gt;Practical applications&lt;/strong&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In customer service, Apify's web scraping abilities are already &lt;a href="https://blog.apify.com/intercom-customer-support-ai-chatbot-web-scraping/" rel="noopener noreferrer"&gt;enhancing AI chatbots&lt;/a&gt;, enabling them to provide accurate and relevant responses based on real-time data.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🦾You might be interested in how you can add &lt;a href="https://blog.apify.com/add-custom-actions-to-your-gpts/" rel="noopener noreferrer"&gt;custom actions to your GPTs&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>ai</category>
      <category>data</category>
      <category>webcrawling</category>
    </item>
    <item>
      <title>How to download and upload files in Puppeteer</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Tue, 21 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/how-to-download-and-upload-files-in-puppeteer-3cmb</link>
      <guid>https://forem.com/apify/how-to-download-and-upload-files-in-puppeteer-3cmb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey, we're&lt;/strong&gt; &lt;a href="https://apify.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;, the only full-stack web scraping and automation library. Check out some of our easy to use&lt;/strong&gt; &lt;a href="https://apify.com/templates" rel="noopener noreferrer"&gt;&lt;strong&gt;web scraping code templates&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;if you want to get started on building your own Puppeteer scrapers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pptr.dev/" rel="noopener noreferrer"&gt;Puppeteer&lt;/a&gt; is a Node.js library that allows you to interact with &lt;code&gt;headless&lt;/code&gt; and &lt;code&gt;headful&lt;/code&gt; Chrome browsers. It enables you to perform lots of tasks, such as navigating web pages, taking &lt;a href="https://blog.apify.com/puppeteer-screenshot-pdf-how-to/" rel="noopener noreferrer"&gt;screenshots, generating PDFs&lt;/a&gt;, and handling filesboth downloads and uploads. Puppeteer essentially allows you to automate tasks that would typically require manual intervention in a web browser.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  &lt;strong&gt;Why handle file downloads and uploads?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;File downloads and uploads are common activities when automating web interactions. Whether you're scraping data from websites, testing file upload functionality, or automating document retrieval, Puppeteer's ability to download and upload files makes it an invaluable tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setting up Puppeteer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To set up Puppeteer, you need to have &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; installed on your computer. If you haven't installed it yet, you can follow this &lt;a href="https://blog.apify.com/how-to-install-nodejs/" rel="noopener noreferrer"&gt;guide&lt;/a&gt; for a step-by-step procedure on how to do it.&lt;/p&gt;

&lt;p&gt;Once Node.js is installed, it will also install &lt;code&gt;npm&lt;/code&gt; for you. You can verify this by opening your command prompt (CMD) or your terminal and using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v &amp;amp;&amp;amp; npm -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will look like the image below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdojyryrv5haf6g1y7lpk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdojyryrv5haf6g1y7lpk.png" alt="terminal screenshot, showing node and npm version installed on a computer" width="800" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Node and NPM version installed on a computer&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After that, you can go to your desired location on your computer to create a folder (either desktop or documents) for your project. You'll initialize a new Node.js project in the folder you created using &lt;code&gt;npm init&lt;/code&gt;, which will bring up some prompts. Follow through with the prompts, and that will set you up.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Installing Node.js&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the image above, a folder called &lt;code&gt;puppeteer-download-upload&lt;/code&gt; is created. The &lt;code&gt;cd puppeteer-download-upload&lt;/code&gt; command is used to change your directory into the folder, and the &lt;code&gt;npm init&lt;/code&gt; command is used to initialize Node.js into the folder. The prompts came up and were filled in accordingly.&lt;/p&gt;

&lt;p&gt;This is so you can run &lt;code&gt;Node.js&lt;/code&gt; operations within the project.&lt;/p&gt;

&lt;p&gt;The next step is for you to install Puppeteer.&lt;/p&gt;

&lt;p&gt;In the same project folder, open your terminal, change your directory, and run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install puppeteer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;📒&lt;em&gt;Note: Anytime you're working on a new Puppeteer project, you'll have to perform these operations:&lt;/em&gt;  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new project folder
&lt;/li&gt;
&lt;li&gt;Initialize Node into the folder
&lt;/li&gt;
&lt;li&gt;Install Puppeteer&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;With Puppeteer successfully installed, you're ready to start automating.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Performing download operations with Puppeteer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To perform a download operation with Puppeteer, you'll need a method to trigger the download action, specify the path at which you want the file to be downloaded, and finally take the download action. After deciding on the method, specify the download path and then trigger the download action by navigating to the page or link and clicking the download link.&lt;/p&gt;

&lt;p&gt;There are various methods and approaches you can use to perform download operations with Puppeteer. Here are three of them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Intercepting network requests using &lt;code&gt;page.setRequestInterception(true)&lt;/code&gt;. You can use this to detect a request for a file download based on the content. If you want to learn more about this method, you should read about &lt;a href="https://pptr.dev/api/puppeteer.page.setrequestinterception" rel="noopener noreferrer"&gt;request interception&lt;/a&gt; in the Puppeteer documentation.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;await page.setRequestInterception(true);page.on('request', (interceptedRequest) =&amp;gt; { // Check the URL or content type to detect a download request if (interceptedRequest.url().endsWith('.pdf')) || interceptedRequest.url().endsWith('.jpg') { // Handle the download here... } interceptedRequest.continue();});// If the file download doesn't start right away, click a button to trigger itawait page.click('#downloadButton')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Browser Contexts and &lt;code&gt;setDownloadBehavior&lt;/code&gt;. This is a more direct way to handle downloads using Puppeteer. In this case, when the download is triggered, the file will automatically be downloaded to the specified directory or path. The previous version used the &lt;code&gt;page._client&lt;/code&gt; private API, but it was deprecated. Instead, you should create your own &lt;a href="https://pptr.dev/api/puppeteer.cdpsession" rel="noopener noreferrer"&gt;CDP sessions&lt;/a&gt; for access to the &lt;a href="https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-setDownloadBehavior" rel="noopener noreferrer"&gt;Chrome dev protocol&lt;/a&gt; directly, like so:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const browser = await puppeteer.launch({ headless: false });const page = await browser.newPage()const client = await page.target().createCDPSession()await client.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: '/path/to/save/downloads' });// If the file download doesn't start right away, click a button to trigger itawait page.click('#downloadButton')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each of the methods listed above is suited to different download scenarios. Just choose the one that best fits the project or task you're working on.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Tips for handling errors&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Handle timeout within your code to give more time for the download operation to be completed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To ensure the file is downloaded successfully, you can use the &lt;code&gt;[page.waitForResponse](&amp;lt;https://pptr.dev/api/puppeteer.page.waitforresponse&amp;gt;)&lt;/code&gt; and &lt;code&gt;targetcreated&lt;/code&gt; conditions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can also check the specified directory manually to ensure the file exists and is of the expected size.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Uploading files with Puppeteer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To perform an upload operation with Puppeteer, you'll need a method that lets you perform the file selection option, specify the path at which you want the file to be selected from, and then finally take the upload action.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;elementHandle.uploadFile(...path)&lt;/code&gt; method that allows you to upload a file by providing the path, or you can use the &lt;code&gt;fileChooser&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;FileChooser&lt;/code&gt; works when the file chooser has a dialog while &lt;code&gt;elementHadle.uploadFile&lt;/code&gt; works directly with the file input element. The method you use depends on the scenario you're working with. If the webpage has a custom button or hides the original file input, &lt;code&gt;FileChooser&lt;/code&gt; is advisable. If you're dealing with a standard file input, &lt;code&gt;elementHandle.uploadFile&lt;/code&gt; is a better option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//the code sample of FileChooserconst [fileChooser] = await Promise.all([page.waitForFileChooser(), page.click('#customUploadButton')]);await fileChooser.accept(['/path/file.jpg']);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;








&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//code sample for ElementHandle.uploadFileconst UploadElement = await page.$('input[type="file"]');await uploadElement.uploadFile('/path/file.jpg');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After deciding on the method, specify the path and then trigger the upload action (navigate to the page or link, click the upload button, and submit).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Best practices for secure file uploads&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Check the file type required for upload and make sure you're uploading the correct file type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check and verify the file input and button selectors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor and handle network requests accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Examples of using upload and download&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this section, you'll be trying out the upload and download options available in Puppeteer.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Automating a file upload with Puppeteer&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the code below, you'll set up your Puppeteer project as explained earlier, create a new file called &lt;code&gt;upload.js&lt;/code&gt;, import Puppeteer, then add a &lt;code&gt;test pdf file&lt;/code&gt; in the root folder for the purpose of the example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import puppeteer from "puppeteer";// function to handle timeout for every action to be completedfunction delay(time) { return new Promise(resolve =&amp;gt; setTimeout(resolve, time));} const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); await page.goto('&amp;lt;https://easyupload.io/&amp;gt;'); await page.waitForSelector('input[type=file]'); const inputUploadHandle = await page.$('input[type=file]'); // path to the file you want to upload await inputUploadHandle.uploadFile('./testdoc.pdf'); await page.click('#upload'); // Introduce a timeout if necessary (in case of internet speed) await delay(20000); // Wait for a success message. await page.waitForSelector('.upload-success'); await browser.close();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2. Automating the download of the file you uploaded earlier&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the previous example, you uploaded a file to &lt;code&gt;[easyupload.io](&amp;lt;http://easyupload.io&amp;gt;)&lt;/code&gt;, after which you were given a download link. Copy the download link to the file, and replace it with the URL in &lt;code&gt;page.goto('...')&lt;/code&gt;. Also, create a folder named &lt;code&gt;downloads&lt;/code&gt;. This is where your file will be downloaded.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import puppeteer from 'puppeteer'import * as fs from 'fs';//function to handle timeout function delay(time) { return new Promise(resolve =&amp;gt; setTimeout(resolve, time)); } const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); // Set download behavior const client = await page.target().createCDPSession() await client.send('Page.setDownloadBehavior', { behavior: 'allow', // the download path can be set to a folder in your project root downloadPath: './downloads' }); // Navigate to the download page. (change the download URL) await page.goto('&amp;lt;https://easyupload.io/x2na1r&amp;gt;'); // Download the file. await page.click('#hd1'); // Wait for the download to complete. Adjust this based on your network speed. await delay(10000);; //check the download folder to know if the downloaded file exists there if (fs.existsSync('./downloads/testdoc.pdf')) { console.log('file downloaded successfully!'); } else { console.log('Download failed.'); } await browser.close();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3. Another code sample for upload and download actions with Puppeteer&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import puppeteer from 'puppeteer'//function to handle timeoutfunction delay(time) { return new Promise(resolve =&amp;gt; setTimeout(resolve, time));} const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); const client = await page.target().createCDPSession(); await client.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: './downloads' }); await page.goto('&amp;lt;https://imgur.com/upload&amp;gt;'); const uploadSelector = '#file-input'; await page.waitForSelector(uploadSelector); const inputUploadHandle = await page.$(uploadSelector); await inputUploadHandle.uploadFile('./cap.jpeg'); //wait for the upload to be completed await delay(10000); // initiate the download process and click the download button const downloadLinkSelector = '.upload-download'; await page.waitForSelector(downloadLinkSelector); await page.click(downloadLinkSelector); //wait for the file download to await delay(10000); await browser.close();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find some more examples of &lt;a href="https://docs.apify.com/academy/puppeteer-playwright/common-use-cases/downloading-files" rel="noopener noreferrer"&gt;downloading files in Puppeteer&lt;/a&gt; and &lt;a href="https://docs.apify.com/academy/puppeteer-playwright/common-use-cases/submitting-a-form-with-a-file-attachment" rel="noopener noreferrer"&gt;submitting a form with an attachment&lt;/a&gt; in the Apify docs.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;GitHub gists&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can explore all the sample code in this tutorial in the GitHub gists below.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://gist.github.com/CodeLeom/bd4c7c17a0749044f7a1a9b606c3e5ae" rel="noopener noreferrer"&gt;Upload&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://gist.github.com/CodeLeom/6f3055951fca57d36819feb5143187cf" rel="noopener noreferrer"&gt;Download&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://gist.github.com/CodeLeom/c5ce35fec15359786045208ddc24a4e0" rel="noopener noreferrer"&gt;Upload and Download&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💻&lt;a href="https://blog.apify.com/puppeteer-web-scraping-tutorial/" rel="noopener noreferrer"&gt;How to scrape the web with Puppeteer in 2023&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>puppeteer</category>
      <category>node</category>
      <category>automation</category>
    </item>
    <item>
      <title>Step-by-step guide to scraping Steam Store</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Wed, 15 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/step-by-step-guide-to-scraping-steam-store-4kec</link>
      <guid>https://forem.com/apify/step-by-step-guide-to-scraping-steam-store-4kec</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey, we're Apify. You can run any scrapers on the Apify platform. Build your own or use one of&lt;/strong&gt; &lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;&lt;strong&gt;1,500+ pre-built scrapers&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;for popular websites.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're looking to extract detailed information from Steam store pages, Steam Store Scraper on Apify is a tool designed to simplify your data collection process. This tutorial will walk you through the steps to configure and use Steam Store Scraper to gather data from Steam's frontpage, which you can then use for analysis or integration with other applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Getting started with Steam Store Scraper&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Steam Store Scraper is a straightforward &lt;a href="https://apify.com/actors" rel="noopener noreferrer"&gt;Apify Actor&lt;/a&gt;, crafted to scrape Steam's frontpage and individual store pages, extracting data like game titles, descriptions, prices, reviews, and more. The output is structured in a convenient dataset that can be exported in various formats, such as JSON, XML, CSV, and Excel.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Steam Store Scraper on Apify Store&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1: Accessing Steam Store Scraper&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To begin, navigate to the &lt;a href="https://apify.com/m0uka/steam-store-scraper" rel="noopener noreferrer"&gt;Steam Store Scraper page on Apify Store&lt;/a&gt;. Here, you will find a brief description of the tool and a "Try for free" button which you can click to start using the scraper without the need for a credit card. The scraper is free to use and you will only pay for your usage of the Apify platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Setting scraping input parameters&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once you're on the Steam Store Scraper page, switch to the &lt;code&gt;Input&lt;/code&gt; tab. This is where you will define the parameters for the data you wish to scrape. The input settings include options such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Only on sale&lt;/strong&gt; : Toggle this if you're only interested in games currently on sale.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Only released&lt;/strong&gt; : Use this filter to exclude games that haven't been released yet.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Expand the &lt;code&gt;Run options&lt;/code&gt; if you need to customize advanced settings like the proxy configuration.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Steam Store parameters&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3: Running the scraper&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After setting your desired parameters, click the &lt;code&gt;Save&lt;/code&gt; button to preserve your configuration. Then, hit the &lt;code&gt;Run&lt;/code&gt; button to initiate the scraping process. The tool will now start crawling through the Steam store based on your specified criteria.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 4: Extracting the data&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once the scraper has completed its run, you can download the dataset. Navigate to the &lt;code&gt;Runs&lt;/code&gt; tab to view the finished runs. Click on a specific run to see the results and choose the format for data export. For instance, if you need to integrate the data with a web application, you might opt for JSON.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Example of extracted data&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is the kind of data you can expect from Steam Store Scraper:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;URL&lt;/strong&gt; : Direct link to the game's Steam page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Title&lt;/strong&gt; : Name of the game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt; : A brief summary or pitch of the game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Price&lt;/strong&gt; : Current price, along with sale information if applicable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Release date&lt;/strong&gt; : Official release date of the game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Genres&lt;/strong&gt; : Game genres such as Action, RPG, Strategy, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Popular tags&lt;/strong&gt; : Tags that users have associated with the game.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reviews&lt;/strong&gt; : Recent and overall review status, like "Very Positive" or "Mixed".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Languages&lt;/strong&gt; : Supported languages for interface, sound, and subtitles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Developers and publishers&lt;/strong&gt; : Companies responsible for the game's development and distribution.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For instance, a sample entry for "Age of Empires IV: Anniversary Edition" would include its price, sale status, release date, genres, supported platforms, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to use the extracted Steam data&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The data obtained from the Steam Store Scraper can be used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Market analysis&lt;/strong&gt; : Understand trends, popular genres, and pricing strategies in the gaming market.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Competitive analysis&lt;/strong&gt; : Compare game features, pricing, and reviews to gauge the competition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data integration&lt;/strong&gt; : Incorporate the dataset into your applications, websites, or research projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or you could just use it to find your next game!&lt;/p&gt;

</description>
      <category>webscraping</category>
    </item>
    <item>
      <title>Add custom actions to your GPTs with Apify Actors</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Tue, 14 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/add-custom-actions-to-your-gpts-with-apify-actors-3a77</link>
      <guid>https://forem.com/apify/add-custom-actions-to-your-gpts-with-apify-actors-3a77</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hi, were&lt;/strong&gt; &lt;a href="https://apify.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;, a full-stack web scraping and browser automation platform. A big part of what we do is getting better&lt;/strong&gt; &lt;a href="https://apify.com/data-for-generative-ai" rel="noopener noreferrer"&gt;&lt;strong&gt;data for AI&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the DevDays keynote on November 6, 2023, OpenAI released &lt;a href="https://openai.com/blog/introducing-gpts" rel="noopener noreferrer"&gt;GPTs&lt;/a&gt; - a new way to build custom AI agents based on ChatGPT - which can use custom instructions and actions provided by third-party APIs to give the agent new capabilities for new use cases.&lt;/p&gt;

&lt;p&gt;Apify now makes it easy to connect any of the 1,500+ Actors from &lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;Apify Store&lt;/a&gt; to your GPTs to give them &lt;a href="https://blog.apify.com/what-is-web-scraping/" rel="noopener noreferrer"&gt;web scraping&lt;/a&gt; and browser automation capabilities, such as fetching data from search engines, maps, social media, travel sites, or extracting data from any website.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What are GPTs?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;OpenAI &lt;a href="https://openai.com/blog/new-models-and-developer-products-announced-at-devday" rel="noopener noreferrer"&gt;released GPTs&lt;/a&gt; at the November 2023 DevDays keynote as a new way to build your own custom AI agents based on the ChatGPT model. GPTs enhance ChatGPT with custom text instructions to prime the model to behave a certain way using the following &lt;a href="https://blog.apify.com/what-is-retrieval-augmented-generation/" rel="noopener noreferrer"&gt;retrieval-augmented generation&lt;/a&gt; (RAG) extensions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Built-in browser, data analytics, DALL-E 3 - they now run together in the same chat session; you dont need to pick just one as before.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;External knowledge imported as static files, such as TXT, JSON, PDF, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;External actions described using an OpenAPI specification and invoked using the models &lt;a href="https://platform.openai.com/docs/guides/function-calling" rel="noopener noreferrer"&gt;function calling&lt;/a&gt; capability.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;a href="https://openai.com/blog/introducing-gpts" rel="noopener noreferrer"&gt;GPTs&lt;/a&gt; from OpenAI&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Evolution of ChatGPT Plugins&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;GPTs are an iteration of the ChatGPT plugins introduced in March 2023. The big change is that while ChatGPT plugins can only use actions provided by an API running on the same domain as the plugin itself, the GPTs can perform actions from any API, even a third-party one.&lt;/p&gt;

&lt;p&gt;For example, the &lt;a href="https://docs.apify.com/platform/integrations/chatgpt-plugin" rel="noopener noreferrer"&gt;Apify ChatGPT plugin&lt;/a&gt; could only invoke actions running on &lt;code&gt;api.apify.com&lt;/code&gt;, but not from &lt;code&gt;api.example.com&lt;/code&gt;. And this restriction also meant that other ChatGPT plugins couldnt use &lt;code&gt;api.apify.com&lt;/code&gt;. This changes now, as GPTs can be used with any API. This has greatly expanded the number of things that chat-based agents can do.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Examples of GPTs with actions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Its hard to keep track of what GPTs people are building (pro tip: the easiest way is to type &lt;code&gt;site:chat.openai.com/g&lt;/code&gt;into &lt;a href="https://www.google.com/search?q=site%3Achat.openai.com%2Fg" rel="noopener noreferrer"&gt;Google Search&lt;/a&gt;). Here are some interesting examples of GPTs that use custom actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://chat.openai.com/g/g-LYDRCiZB9-yc-application-gpt" rel="noopener noreferrer"&gt;&lt;strong&gt;YC Application GPT&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;:&lt;/strong&gt; Automatically fills YC applications for you based on website or Pitch Deck.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://chat.openai.com/g/g-n7Rs0IK86-grimoire" rel="noopener noreferrer"&gt;&lt;strong&gt;Grimoire&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;:&lt;/strong&gt; A coding GPT that lets you create a website with a sentence, or even from a paper sketch or screenshot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://chat.openai.com/g/g-tBei7TkK0-spotify-explorer-gpt" rel="noopener noreferrer"&gt;&lt;strong&gt;Spotify Explorer GPT&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;:&lt;/strong&gt; Lets you drop a Spotify link to a song, playlist, user or artist and explore with insights.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://chat.openai.com/g/g-8OcWVLenu-calendar-assistant-gpt" rel="noopener noreferrer"&gt;&lt;strong&gt;Calendar GPT&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;:&lt;/strong&gt; Helps you prepare for your day. Powered by Zapier's AI Actions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://chat.openai.com/g/g-cwigWCh11-code-gpt-gpt" rel="noopener noreferrer"&gt;&lt;strong&gt;Code GPT GPT&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;:&lt;/strong&gt; Helps you understand the rules of the Code GPT repository at &lt;a href="https://github.com/Decron/Code-GPT/" rel="noopener noreferrer"&gt;https://github.com/Decron/Code-GPT/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Using Apify Actors as GPT actions&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Apify Actors can now automatically generate the OpenAPI specification for their API, which makes it extremely easy to call them from your GPTs. This makes it easy to add any of the &lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;1,500+ Actors published in Apify Store&lt;/a&gt; in your GPTs or link your newly built Actors for your use case.&lt;/p&gt;

&lt;p&gt;For example, heres how to create a new GPT agent that can scrape Google Search results and use it to answer user questions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Make sure you have an&lt;/strong&gt; &lt;a href="https://console.apify.com/sign-up" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify account&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Its free. No credit card required, and no time limit on the free plan. You get $5 dollars worth of monthly credit to get you started.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Go to&lt;/strong&gt; &lt;a href="https://console.apify.com/store" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify Store&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and pick&lt;/strong&gt; &lt;a href="https://console.apify.com/actors/nFJndFXA5zjCTuudP/console" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Google Search Scraper&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;3. On the Actor detail page, select &lt;em&gt;API&lt;/em&gt;&lt;em&gt;OpenAPI specification&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;4. Copy the JSON with OpenAPI specification into the clipboard&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;5. Go to ChatGPT&lt;/strong&gt; &lt;a href="https://chat.openai.com/gpts/discovery" rel="noopener noreferrer"&gt;&lt;strong&gt;Explore&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;page, click "&lt;em&gt;Create a GPT"&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;6. Configure your GPT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set its Name, Description, Instructions, and Conversation starters. Uncheck the &lt;em&gt;Web Browsing&lt;/em&gt; capability to avoid interference of the native web browser with Google Search.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;7. Click the &lt;em&gt;Add actions&lt;/em&gt; button, and paste the OpenAPI specification of the Actor from step 4 into the Schema field.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add a link to Apify's privacy policy &lt;a href="https://apify.com/privacy-policy" rel="noopener noreferrer"&gt;https://apify.com/privacy-policy&lt;/a&gt;, so that you can later publish your GPT.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;8. Open a new browser window, go to&lt;/strong&gt; &lt;a href="https://console.apify.com/account/integrations" rel="noopener noreferrer"&gt;&lt;strong&gt;Settings Integrations&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;in Apify Console, and copy your Apify API token&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;9. Edit your GPT's Authentication settings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the settings of your GPT, click Edit in the Authentication section, select API key Authentication Type, Bearer Auth Type, and paste the Apify API key.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;10. Save and publish&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Save the Authentication settings, click Save on your GPT, and publish it to &lt;em&gt;Only people with a link&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;And voil! Your GPT is ready to use, and published at a link (&lt;a href="https://chat.openai.com/g/g-dGlk5uXNj-serp-scraper" rel="noopener noreferrer"&gt;like this one&lt;/a&gt;) that you can share with any ChatGPT user!&lt;/p&gt;

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

&lt;h2&gt;
  
  
  &lt;strong&gt;Benefits of Actors&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://apify.com/actors" rel="noopener noreferrer"&gt;Apify Actors&lt;/a&gt; are a way to package your code that makes it easy to share, integrate, and build upon. Actors are based on Docker images extended with an input and output schema to enable linking, automated generation of user interfaces, and sharing with other users. Now, they can also export the &lt;a href="https://swagger.io/specification/" rel="noopener noreferrer"&gt;OpenAPI specification&lt;/a&gt; for their invocation and return of results.&lt;/p&gt;

&lt;p&gt;Actors run on the Apify cloud platform, which provides compute, storage, and proxy services. It takes care of scaling, authentication, security, and billing. Apify Store features more than 1,500+ ready-made Actors built by the community for various use cases, which you can use right away in your GPTs.&lt;/p&gt;

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

&lt;p&gt;Apify also provides extensive documentation and open-source SDKs, including the popular library &lt;a href="https://crawlee.dev/" rel="noopener noreferrer"&gt;Crawlee&lt;/a&gt;. It also offers &lt;a href="https://apify.com/templates" rel="noopener noreferrer"&gt;Actor templates&lt;/a&gt; for JavaScript/TypeScript and Python and scraping libraries such as Puppeteer, Playwright, or Selenium. All of this means you can quickly build new Actors for your unique web scraping and automation projects and then incorporate them into your GPTs.&lt;/p&gt;

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

&lt;p&gt;Example of &lt;a href="https://crawlee.dev/" rel="noopener noreferrer"&gt;Crawlee&lt;/a&gt; code&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Limitations of Actors and GPTs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Not every Actor is suitable for the above use as a GPT action.&lt;/p&gt;

&lt;p&gt;OpenAI enforces a timeout of 45 seconds for the action to return a result, and thus, the Actor needs to be able to return its output in that timeframe. Otherwise, users of the GPT will see timeout errors.&lt;/p&gt;

&lt;p&gt;The exported OpenAPI specification from Apify Console is intended for running the Actor with a custom input and synchronously returning its output dataset, using the &lt;a href="https://docs.apify.com/api/v2#/reference/actors/run-actor-synchronously-and-get-dataset-items/run-actor-synchronously-with-input-and-get-dataset-items" rel="noopener noreferrer"&gt;Run actor synchronously with input and get dataset items&lt;/a&gt; API endpoint. Therefore, the Actor needs to generate its output to the default dataset to provide results to GPT. For Actors that generate their results to the key-value store, youll need to manually update the OpenAPI specification to use the &lt;a href="https://docs.apify.com/api/v2#/reference/actors/run-actor-synchronously/with-input" rel="noopener noreferrer"&gt;Run Actor synchronously&lt;/a&gt; API endpoint.&lt;/p&gt;

&lt;p&gt;The exported OpenAPI specification covers all input parameters, but for most cases, you only need the model to set a few and keep the rest with default values. Therefore, it might make sense to edit the specification and remove irrelevant input parameters, to avoid eating into GPT model context window size.&lt;/p&gt;

&lt;p&gt;To use multiple Actors in a single GPT, youll need to merge their respective OpenAPI specifications into one.&lt;/p&gt;

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

&lt;p&gt;GPTs are a new, exciting release from OpenAI, and we're curious to see what GPTs people will build, with or without Apify Actors. If you have any feedback or ideas for improvements to the Actor integration for GPTs, we'd love to hear from you! Simply email us at &lt;a href="mailto:ai@apify.com"&gt;ai@apify.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>llms</category>
    </item>
    <item>
      <title>What is an anonymous proxy? A detailed guide for 2024</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Mon, 13 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/what-is-an-anonymous-proxy-a-detailed-guide-for-2024-4iic</link>
      <guid>https://forem.com/apify/what-is-an-anonymous-proxy-a-detailed-guide-for-2024-4iic</guid>
      <description>&lt;p&gt;Have you ever felt like someone's watching every click you make online?&lt;/p&gt;

&lt;p&gt;In the digital realm, protecting your privacy and security isn't just importantit's essential. Think of anonymous proxies as your personal guardians, safeguarding your online persona by masking your actual IP address and providing you with the freedom to surf the web under the radar.&lt;/p&gt;

&lt;p&gt;By the end of this comprehensive guide, you'll have a solid understanding of the intricacies of anonymous proxies, their types, benefits, risks, and how to set them up on various devices. So, get ready to become an anonymous proxy pro!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Understanding anonymous proxies&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Serving as intermediary servers, anonymous proxies conceal the IP address while offering varying levels of anonymity. Their primary purpose is to provide online security and anonymity by altering network traffic and HTTP headers, safeguarding a clients identity. This makes an anonymous proxy a powerful tool for maintaining privacy and anonymity when browsing the internet.&lt;/p&gt;

&lt;p&gt;Proxy anonymity comes in different tiers to match all kinds of user needs and preferences. A transparent proxy, for example, can be used in educational institutions and public Wi-Fi networks, managing website traffic without hiding the users IP address. On the other hand, highly anonymous proxies and elite proxies, due to their higher levels of anonymity, are more suited for users who prioritize online privacy.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Types of proxies&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Based on their level of anonymity and functionality, &lt;a href="https://blog.apify.com/types-of-proxies/" rel="noopener noreferrer"&gt;proxies can be grouped&lt;/a&gt; into three main types: elite, anonymous, and transparent proxies.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Elite proxies provide the highest security, completely masking the users IP address and proxy use.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anonymous proxies hide the users real IP address to a mid-level, offering increased privacy but allowing some headers to pass along to the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transparent proxies don't provide anonymity to the user, allowing web activities to be traced. To keep the user entirely anonymous, the following headers might be removed:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Authorization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proxy-Authorization&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proxy-Connection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Via&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;X-Forwarded-For&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h3&gt;
  
  
  &lt;strong&gt;How do anonymous proxies work?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Anonymous proxies enhance online privacy and security by channeling user requests via a &lt;a href="https://blog.apify.com/what-is-a-proxy-server/" rel="noopener noreferrer"&gt;proxy server&lt;/a&gt;, which replaces the users original IP address with its own proxy. This creates a layer of anonymity, making it seem as though the user is accessing the internet through a different location. Such proxies are crucial for personal and business use, offering a shield against data breaches and unwanted surveillance by concealing the users digital footprint.&lt;/p&gt;

&lt;p&gt;They strengthen privacy and security in personal and business applications by routing user requests through an anonymous proxy server, obscuring their IP address in the process. These anonymous proxy services ensure a higher level of protection for users, making an anonymous proxy tool essential for maintaining online privacy. With these services, proxy anonymity exists, safeguarding user information.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Benefits of using anonymous proxies&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The use of anonymous proxies comes with many advantages, such as bypassing online censorship, accessing geo-limited content, and ensuring user privacy. By concealing your IP address, anonymous proxies guarantee anonymity while browsing and can help you bypass geo-restrictions to access content that is otherwise unavailable in your area.&lt;/p&gt;

&lt;p&gt;🔍 Let's examine the benefits of anonymous proxies in both personal and business scenarios.&lt;/p&gt;

&lt;p&gt;For &lt;em&gt;personal&lt;/em&gt; use, anonymous proxies enable users to bypass geo-restrictions and preserve online privacy. Bypassing geo-restrictions allows users to access content that is otherwise blocked in their region, such as streaming services, multiple social media accounts, or news websites.&lt;/p&gt;

&lt;p&gt;Other personal applications of anonymous proxies include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Improving the browsing experience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accessing restricted content&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Preserving online identity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conducting secure online transactions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Engaging in anonymous communication&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💼 In the &lt;em&gt;business&lt;/em&gt; world, anonymous proxies find applications in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://blog.apify.com/what-is-web-scraping/" rel="noopener noreferrer"&gt;Web scraping&lt;/a&gt;: involves extracting data from websites, and anonymous proxies help prevent scraping bots from being blocked by the target website by masking the bots IP address.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Brand protection: anonymous proxies can be used to monitor online platforms and detect any unauthorized use of a brands intellectual property.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reputation intelligence missions: anonymous proxies can be used to gather information about a companys online reputation and monitor online discussions and reviews.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZFHXj_lQnOQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;📣 Anonymous proxies can be used for brand protection, ensuring that businesses can monitor online activities and safeguard their online presence effectively.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Risks and limitations of anonymous proxies&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While anonymous proxies offer advantages, they possess potential risks and limitations like security vulnerabilities, reduced speeds, and reliability. Free anonymous proxies can be slow, overutilized, and may inject malware into ones device or browser, while some can be set up as traps by governments or hackers to identify and compromise user data.&lt;/p&gt;

&lt;p&gt;Risk mitigation involves making an informed choice between free and premium proxies and selecting an appropriate proxy service.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;💰 Free vs. premium proxies&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Free proxies often come with risks and performance issues, unlike premium proxies, which are reputable for their heightened security and effectiveness. There's a chance that complimentary proxies might compromise personal information or introduce malware to a users system. On the other hand, premium proxies ensure a secure and stable online experience.&lt;/p&gt;




&lt;p&gt;Check out these &lt;a href="https://blog.apify.com/get-proxies-free-proxy-services/" rel="noopener noreferrer"&gt;10 free or low-cost proxy services&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;To ensure optimal security and performance, its crucial to choose a reputable proxy provider and consider factors such as the providers reputation, the types of proxies they offer, and the locations of their servers.&lt;/p&gt;




&lt;p&gt;Read more about &lt;a href="https://blog.apify.com/automatically-scrape-free-proxy-lists-to-check-for-working-proxies/" rel="noopener noreferrer"&gt;how to scrape free proxy lists&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Choosing the right proxy service&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Choosing a suitable anonymous proxy and service is essential to ensure optimal security and efficiency. When choosing an anonymous proxy service, consider the following factors:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Compatibility&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proxy types&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Anonymity levels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IP pools and performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use case and budget&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A secure and efficient browsing experience can be ensured by assessing your needs and the offerings of different proxy providers, including your internet service provider.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;💓&lt;a href="https://blog.apify.com/best-proxy-providers/" rel="noopener noreferrer"&gt;&lt;strong&gt;Best proxy providers&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🔧 Setting up and configuring anonymous proxies&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To set up and configure anonymous proxies on various devices and browsers, youll need to adjust the settings within the browser or device. This includes altering the proxy settings, activating the proxy, and entering the proxy server address.&lt;/p&gt;

&lt;p&gt;We'll now focus on the configuration of anonymous proxies on Windows and Mac computers, various popular web browsers, and the web server settings for mobile devices.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Browser settings&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To configure anonymous proxies on popular browsers like Chrome, Firefox, and Safari, youll need to adjust their respective proxy settings. In Chrome, access Settings from the toolbar, select Advanced followed by Settings and then System, open your computers proxy settings, and select Manual proxy setup. Enter the address of your proxy server and a proxy port number, then click Save.&lt;/p&gt;

&lt;p&gt;Go to the Safari toolbar and select Preferences. Then go to the Advanced tab and select Proxies, then Change settings.&lt;/p&gt;

&lt;p&gt;📱For mobile devices setting up anonymous proxies on mobile devices, including Android and iOS, might require a different approach. While there isnt a specific process for setting up anonymous proxies on mobile devices, it is generally recommended to &lt;a href="https://nordvpn.com/blog/how-to-use-a-vpn/" rel="noopener noreferrer"&gt;use a VPN&lt;/a&gt; service for Android devices.&lt;/p&gt;

&lt;p&gt;For iOS devices, you can configure proxy settings within the Wi-Fi settings and input the server address, same IP name, port number, and any necessary authentication information.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  &lt;strong&gt;🔎 Comparing anonymous proxies and VPNs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Both anonymous proxies and VPNs offer a degree of anonymity and security. However, there are some key differences between the two. VPNs, such as &lt;a href="https://cybernews.com/best-vpn/nordvpn-vs-expressvpn/" rel="noopener noreferrer"&gt;ExpressVPN or NordVPN&lt;/a&gt;, offer more features and greater security, as they encrypt all of your internet traffic, while proxy servers only conceal your IP address for specific websites or applications.&lt;/p&gt;

&lt;p&gt;Now let's delve into the distinctions in anonymity, security, speed, and performance between anonymous proxies and VPNs.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Anonymity and security&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;While both anonymous proxies and &lt;a href="https://www.privacyjournal.net/top-best-vpn/" rel="noopener noreferrer"&gt;VPNs provide anonymity&lt;/a&gt;, VPNs offer better security through encryption. VPNs secure all network traffic from a single IP address, while anonymous proxies can make use of multiple IP addresses.&lt;/p&gt;

&lt;p&gt;Additionally, VPNs encrypt traffic, providing a higher degree of security in comparison to anonymous proxies, which do not offer the same level of encryption.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Speed and performance&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;VPNs may offer better speed and performance compared to anonymous proxies, depending on the provider and server locations. Generally, VPNs are faster because they are built to manage and encrypt all internet traffic, providing a more effective and secure connection. Proxies, on the other hand, tend to only function with a single application or service, which can lead to slower speeds.&lt;/p&gt;

&lt;p&gt;Factors that can impact the speed and performance of both anonymous proxies and VPNs include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Server location&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Number of users connected to the server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type of encryption employed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type of traffic being transmitted&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Troubleshooting common proxy issues&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Anonymous proxies oftentimes come with issues like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;a high number of website IP bans&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;proxy provider failures&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;improper configuration for a specific browser or operating system&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;proxy server errors like HTTP error status codes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Addressing these issues may require handling Anonymous Proxy Detected errors and ensuring the optimal performance of the proxy.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Resolving "anonymous proxy detected" errors&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you encounter an Anonymous Proxy Detected error message, you might need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Close all applications before using proxies&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clear the cookies and cache of the browser&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the proxy rotation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Attempt shorter intervals per session&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These measures can help address the error message and ensure a smoother browsing experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🔑 Key takeaways&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Anonymous proxies enhance security and anonymity by modifying network traffic and HTTP headers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Different types of proxies offer different levels of privacy, making them beneficial for personal and business use cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When choosing a proxy service, consider compatibility, type, level of anonymity, and performance to ensure optimal results.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;That's a wrap! Now you know how proxy servers work 🦾&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To ensure optimal proxy performance, choose a reputable provider with diverse servers, reliable performance, and secure connections. Regularly update your proxy settings for a secure and high-performing connection. If proxy settings are not functioning as intended, verify that the proxy settings are properly configured and that the connection is secure.&lt;/p&gt;

&lt;p&gt;Anonymous proxies are powerful tools for maintaining online privacy and anonymity. By understanding their types, benefits, risks, and how to set them up on various devices, you can harness their potential to safeguard your online identity and access restricted content. However, it is essential to weigh the pros and cons of using proxy servers versus VPNs and to choose a reputable provider for optimal security and performance.&lt;/p&gt;

&lt;p&gt;Check out &lt;a href="https://apify.com/proxy" rel="noopener noreferrer"&gt;Apify Proxy&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>proxy</category>
      <category>webcrawling</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>Connecting web scrapers: a guide to Actor-to-Actor integrations</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Sun, 12 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/connecting-web-scrapers-a-guide-to-actor-to-actor-integrations-1d83</link>
      <guid>https://forem.com/apify/connecting-web-scrapers-a-guide-to-actor-to-actor-integrations-1d83</guid>
      <description>&lt;p&gt;If you're an Apify user, you're no doubt familiar with the serverless cloud programs (or micro-apps) we call &lt;a href="https://apify.com/actors" rel="noopener noreferrer"&gt;&lt;strong&gt;Actors&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You're also probably aware that you can &lt;a href="https://apify.com/integrations" rel="noopener noreferrer"&gt;&lt;strong&gt;integrate Actors&lt;/strong&gt;&lt;/a&gt; and their tasks with your favorite web apps and cloud services. But now it's possible to &lt;a href="https://docs.apify.com/platform/integrations/actors" rel="noopener noreferrer"&gt;&lt;strong&gt;integrate Actors with other Actors&lt;/strong&gt;&lt;/a&gt;. That means you can reuse existing Actors instead of building your own to complete certain processes.&lt;/p&gt;

&lt;p&gt;Say you have one Actor with a dataset containing URLs and another that takes URLs and downloads them as images. Integrating the two makes the whole process of retrieving and downloading images so much easier than it used to be.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Connecting two Actors can simplify your workflow&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You may have noticed that some Actors have an Actor-specific integration available. For example, &lt;a href="https://apify.com/compass/crawler-google-places" rel="noopener noreferrer"&gt;&lt;strong&gt;Google Maps Scraper&lt;/strong&gt;&lt;/a&gt; has the &lt;a href="https://apify.com/geneea-analytics/reviews-text-nlp-analyzer" rel="noopener noreferrer"&gt;&lt;strong&gt;AI Text Analyzer for Google Reviews&lt;/strong&gt;&lt;/a&gt; as a recommended integration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3nlbs9c9fznpv9pbddnf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3nlbs9c9fznpv9pbddnf.png" alt="AI Text Analyzer under Google Maps Scraper's integration tab" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI Text Analyzer under Google Maps Scraper's integration tab&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But this doesn't mean you're limited to integrating just this one Actor. You can connect any Actor or task with the Apify integration.&lt;/p&gt;

&lt;p&gt;In this step-by-step guide, we're going to show you an example by connecting two Actors via the Apify integration.&lt;/p&gt;

&lt;p&gt;Prefer video? Watch this instead:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/zExnYbvFoBM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1. Choose an Actor&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Start by going straight to &lt;a href="https://console.apify.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify Console&lt;/strong&gt;&lt;/a&gt;. If you're not an Apify user, you'll need to sign up for a free account before you start.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🆓&lt;a href="https://console.apify.com/sign-up" rel="noopener noreferrer"&gt;&lt;strong&gt;Sign up for free&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We're going to choose &lt;a href="https://apify.com/apify/cheerio-scraper" rel="noopener noreferrer"&gt;&lt;strong&gt;Cheerio Scraper&lt;/strong&gt;&lt;/a&gt; with the purpose of connecting it with the &lt;a href="https://apify.com/zuzka/download-images-from-dataset" rel="noopener noreferrer"&gt;&lt;strong&gt;Download Images from Dataset&lt;/strong&gt;&lt;/a&gt; Actor.&lt;/p&gt;

&lt;p&gt;What we want to do is grab all image URLs from the &lt;a href="https://blog.apify.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify Blog&lt;/strong&gt;&lt;/a&gt; (because it's awesome) with &lt;strong&gt;Cheerio Scraper&lt;/strong&gt; (because it's super fast) and then download them into a zip file using &lt;strong&gt;Download Images from Dataset&lt;/strong&gt;. So, we're using one Actor to grab the URLs of the images, and with the other, we're downloading the images (not just the URLs) as a zip file.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2. Create a task with the Actor&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First, you need to create a task. Tasks are great for organizing your inputs, especially if you want to connect more than two Actors.&lt;/p&gt;

&lt;p&gt;In this example, we'll create a task with Cheerio Scraper, which we'll call &lt;em&gt;Apify Blog Image Grabber.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Hit "Create new task" at the top of the Actor input page&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next, we'll put the URL for the Apify Blog in the Start URLs field.&lt;/p&gt;

&lt;p&gt;We have no need for &lt;em&gt;Glob patterns&lt;/em&gt; or &lt;em&gt;Link selectors&lt;/em&gt;, so we'll leave those blank. What we do need is code in the &lt;em&gt;Page function&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Edit your scraper's input accordingly&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here, we're creating a &lt;code&gt;pageFunction&lt;/code&gt; where we're iterating through all images on the page, getting a URL of each image, and pushing the full image URL to a dataset.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16ri1lw2rztqfw6dci00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F16ri1lw2rztqfw6dci00.png" alt="Our code will push image URLs found on the website to a dataset" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Our code will push image URLs found on the website to a dataset&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3. Choose the Actor to integrate with&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now go to &lt;strong&gt;Integrations&lt;/strong&gt; , click the &lt;strong&gt;Apify integration&lt;/strong&gt; , and then choose the Actor you want to integrate it with.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Connect the Actor you want to integrate&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first Actors you'll see (in alphabetical order) are integration-ready Actors. You can also find these in &lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify Store&lt;/strong&gt;&lt;/a&gt; under the &lt;em&gt;Integrations&lt;/em&gt; category.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;You can find integration-ready Actors in Apify Store&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We'll select &lt;em&gt;Download Images From Dataset&lt;/em&gt; and click &lt;em&gt;Connect&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 4. Choose a trigger&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now you can choose the &lt;em&gt;Trigger&lt;/em&gt; that will start the Download Images Actor. We'll stick with &lt;em&gt;Run succeeded&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Because we're using an integration, the dataset ID field is already prefilled with the datasetID that Cheerio Scraper will generate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihy8vxdpjh4uwfzjltim.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihy8vxdpjh4uwfzjltim.png" alt="Choose a trigger to run the second Actor: note the Dataset ID is prefilled from Cheerio Scraper!" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Choose a trigger to run the second Actor: note the Dataset ID is prefilled from Cheerio Scraper!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5. Save and test settings&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now you can save the integration settings. Once saved, you can test the integration with the test button. You have multiple test settings. We'll test it with &lt;em&gt;last run&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Test your integrations via the Test button&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can see the test results in the &lt;em&gt;log&lt;/em&gt; underneath.&lt;/p&gt;

&lt;p&gt;If you go back to the integrations tab, you can see how the Actors and tasks are connected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8vvqqizs63j1dgf32jm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8vvqqizs63j1dgf32jm.png" alt="View the schema of your Actor connections in the task's Integrations tab" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;View the schema of your Actor connections in the task's Integrations tab&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So now, when we start the &lt;em&gt;Apify Blog Image Grabber&lt;/em&gt; task and go to our runs, we can see that the image downloader was also triggered.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e9ol0ndu8ta7qjpesms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3e9ol0ndu8ta7qjpesms.png" alt="See how the relevant Actors are triggered in the Runs tab" width="800" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;See how the relevant Actors are triggered in the Runs tab&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since the run is finished, lets look at the results. If we go to &lt;em&gt;Storage&lt;/em&gt; and the key-value store, we can see our images archive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feqte8ey7vrmlm9rf9g74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feqte8ey7vrmlm9rf9g74.png" alt="You can find your pictures in the image-archive file in the run's Key-value store" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find your pictures in the image-archive file in the run's Key-value store&lt;/p&gt;

&lt;p&gt;Now we can download it to our device.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Bonus step: schedule tasks&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to automate your workflow further, you can schedule your integration-infused tasks to run at specific times.&lt;/p&gt;

&lt;p&gt;See how to set up a schedule in our video on the topic:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/GRFW_Loo2dk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Which Actors do you want to integrate?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So, now you know how it works, which Actors will you choose to integrate first? There are well over a thousand pre-built web scraping and automation tools in Apify Store to choose from. Take your pick!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🛒&lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;&lt;strong&gt;Browse Apify Store&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create integration-ready Actors&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Don't forget, you can build your own Actors, run them locally on Apify's cloud platform, and publish them in Apify Store to reach people who need your solution and get paid.&lt;/p&gt;

&lt;p&gt;If you want to know how to build integration-ready Actors, the &lt;a href="https://docs.apify.com/platform/integrations/actors/integration-ready-actors" rel="noopener noreferrer"&gt;&lt;strong&gt;guidelines in our documentation&lt;/strong&gt;&lt;/a&gt; will show you what to do.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;😱 &lt;a href="https://docs.apify.com/platform/integrations/actors/integration-ready-actors" rel="noopener noreferrer"&gt;&lt;strong&gt;Create integration-ready Actors&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>integration</category>
      <category>tutorial</category>
      <category>automation</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>How to scrape Google search results</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Fri, 10 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/how-to-scrape-google-search-results-1mnm</link>
      <guid>https://forem.com/apify/how-to-scrape-google-search-results-1mnm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey, we're&lt;/strong&gt; &lt;a href="https://apify.it/web-scraping" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;, and we've been scraping the web for over 8 years. You can build, deploy, share, and monitor fast, reliable web scrapers on the Apify platform.&lt;/strong&gt; &lt;a href="https://apify.it/web-scraping" rel="noopener noreferrer"&gt;&lt;strong&gt;Check us out&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Does Google even need an introduction? If our phones have become extensions of our hands, Google is one of the main reasons for that evolution. Google is a synonym for answers, speed, and accessibility - but also for billions of dollars, users, clicks, searches, and &lt;a href="https://lewisdgavin.medium.com/googles-data-footprint-will-blow-your-mind-2237cf8e0d4" rel="noopener noreferrer"&gt;billions of terabytes&lt;/a&gt; of data. That data can be extracted automatically and effortlessly if you know the proper methods and have the right tools at hand.&lt;/p&gt;

&lt;p&gt;In this brief how-to article, were going to show you exactly how to scrape the most extensive library in the world by using a ready-made tool on the Apify platform called &lt;a href="https://apify.com/apify/google-search-scraper" rel="noopener noreferrer"&gt;Google Search Results Scraper&lt;/a&gt;. This is your step-by-step guide to how to scrape any information available from Google, including organic and paid results, ads, queries, People Also Ask boxes, prices, and reviews. Lets get started!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🪚 &lt;a href="https://apify.com/apify/google-search-scraper" rel="noopener noreferrer"&gt;&lt;strong&gt;Try out Google SERP Scraper&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🕵 What are Google SERPs?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A Google SERP is a page containing the list of search results that Google displays to you when you type in your query and hit Enter. SERP, in this case, stands for &lt;a href="https://en.wikipedia.org/wiki/Search_engine_results_page" rel="noopener noreferrer"&gt;Search Engine Results Page&lt;/a&gt;, and youll find SERPs not only on Google, which controls 90% of the search engine market, but also on other search engines, such as Bing, Yahoo, and others. We need to know this term to understand how to use &lt;a href="https://blog.apify.com/what-is-web-scraping/" rel="noopener noreferrer"&gt;web scraping&lt;/a&gt; on the Google Search Engine. You can consider the terms &lt;code&gt;Google page&lt;/code&gt;&lt;em&gt;,&lt;/em&gt; &lt;code&gt;Google search page&lt;/code&gt;&lt;em&gt;,&lt;/em&gt; and &lt;code&gt;Google SERP&lt;/code&gt; to be equal and interchangeable, but well stick with &lt;code&gt;Google SERP&lt;/code&gt; for the sake of being technically correct.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What do Google SERPs look like?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Google SERPs have changed a lot over the years, with the most prominent features being those infoboxes we all know too well - Knowledge Graphs, Carousels, Featured Snippets - so ubiquitous these days that we cant imagine the Google SERP interface looking any other way. Those now-classic Google SERP features were part of the &lt;a href="https://en.wikipedia.org/wiki/Google_Hummingbird" rel="noopener noreferrer"&gt;Hummingbird algorithm&lt;/a&gt; release in 2013.&lt;/p&gt;

&lt;p&gt;Its a far cry from the 2003 version of Google results. Does this prehistoric SERP interface ring a bell? Luckily, were not there anymore.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh6.googleusercontent.com%2FC3CGRotvHqIJ-oj7wmHrWZ9KDvYBgCmVxpEQyuV5FQt0tGVMncFrQoZpkvzXjMLcLxD3mDK216dctfeTNFEf7UQ1EKk_JVOsNp7kKAuan41V1klvJa8LV_V5cCCP0ke7-kFC8ZxM%3Ds0" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh6.googleusercontent.com%2FC3CGRotvHqIJ-oj7wmHrWZ9KDvYBgCmVxpEQyuV5FQt0tGVMncFrQoZpkvzXjMLcLxD3mDK216dctfeTNFEf7UQ1EKk_JVOsNp7kKAuan41V1klvJa8LV_V5cCCP0ke7-kFC8ZxM%3Ds0" width="760" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Google SERP interface in the beginning of the 2000s&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How do you scrape Google SERP?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To scrape Google search results, we first need to understand how Google sees and prioritizes our searches. When you search for things on Google, what you see is not just an index of pages with URLs or so-called &lt;code&gt;organic searches&lt;/code&gt;. While it used to be like that in the past (as seen above), the primary purpose and driving force of Google - or any search engine for that matter - has always been to have your queries answered as quickly and efficiently as possible, and in a way that will attract your attention but be easy on the eyes.&lt;/p&gt;

&lt;p&gt;Thats why over time, Google search results have become much more multilayered, including the results of varying complexity and formats, like a giant layer cake. And that cake-like structure isnt going away any time soon, with voice command search, apps, and mobile search introducing their significant corrections into the way we google stuff. Today, Google search results consist of various levels, depending on the complexity and type of search, as you can see in this example of a &lt;em&gt;James Webb Space Telescope&lt;/em&gt; query 🔭&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.apify.com%2Fcontent%2Fimages%2F2022%2F09%2Fscreencapture-google-search-2022-09-07-16_07_35-edit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.apify.com%2Fcontent%2Fimages%2F2022%2F09%2Fscreencapture-google-search-2022-09-07-16_07_35-edit.png" alt="Search results for James Webb Telescope" width="800" height="2146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Search results for James Webb Telescope&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What are the elements of a Google search page?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;So these days, Google SERP is packed with various content: featured snippets, so-called snap packs, ads, and organic results. Additional types may also show up: product ads, related searches, and multiple snap pack types (Wikipedia, Google Maps, YouTube videos, etc.)&lt;/p&gt;

&lt;p&gt;The elements you receive will depend on the type of search query. For instance, as the James Webb Telescope is rather scientific and educational content, you won't see paid ads there or a carousel with products. But you will see those when googling everyday objects like shoes or headphones. &lt;strong&gt;Leveraging this complicated Google structure means giving access to an incredible amount of useful data, all of which you can scrape.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🔧 How to use data extracted from Google&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Google is the main entry point to the internet for billions of people. This makes appearing in Google Search results a key factor for almost every business. And Google reviews and ratings have a massive impact on local businesses online profiles. Marketing agencies, especially those with a large number of clients from various industries, rely heavily on obtaining reliable &lt;a href="https://www.dealify.com/all-in-one-seo-tools/" rel="noopener noreferrer"&gt;SEO tools&lt;/a&gt;, including advanced &lt;a href="https://simplified.com/ai-tools/" rel="noopener noreferrer"&gt;AI tools&lt;/a&gt;. They are not only a means of effectively performing multiple tasks but also a means of successful management and analysis of results. You can look for things like how the top-ranking pages are writing their page titles, the keywords they're targeting, how they format their content, or take it a stage further and do some deeper link analysis.&lt;/p&gt;

&lt;p&gt;Typical use cases for Google Search scraping are, among thousands of others:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Analyze Google algorithm&lt;/strong&gt; and identify its main trends&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gain insights for Search engine optimization&lt;/strong&gt; (SEO)monitor how your website performs in Google for specific queries over a period of time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Analyze ads&lt;/strong&gt; ranking for a given set of keywords&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitor competition&lt;/strong&gt; in both organic and paid results&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build a URL list for specific keywords.&lt;/strong&gt; This is useful if you, for example, need good relevant starting points when scraping web pages containing specific phrases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Is it legal to scrape Google?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Google search results fall into the category of publicly available data, so scraping Google search results is legal. But there is still some data you should not be accumulating, such as personal information or copyrighted content. Learn more about regulations and laws connected to scraping at our &lt;a href="https://blog.apify.com/is-web-scraping-legal/" rel="noopener noreferrer"&gt;legality article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🤖 Can I use AI to scrape Google?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;AI is currently unable to scrape websites directly, but it can help generate code for scraping Google if you prompt it with the target elements you want to scrape. Note that the code may not be functional, and website structure and design changes may impact the targeted elements and attributes.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🦾 Does Google search have an API?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Scraping Google search results is how you can create your own Google SERP API (read &lt;a href="https://blog.apify.com/what-is-an-api/" rel="noopener noreferrer"&gt;What is an API?&lt;/a&gt; for more info on APIs) to extract data from Google. But why? Technically, you can fish out some insights into the way Google works and displays results without the need to use any specific tools: just google your keyword and see what you get. Now google the same thing in incognito mode and see what you get again. But there are two problems with this approach.&lt;/p&gt;

&lt;p&gt;First, the process is pretty &lt;strong&gt;time-consuming&lt;/strong&gt; to do manually and at scale - an inefficient monkey job, essentially. Second, the results you get &lt;strong&gt;can't be considered objective&lt;/strong&gt; , even if you're using incognito mode. At the beginning of the 2000s, when the Google SERPs were first introduced, they looked much the same to each user for the localized Google version per each country. Now Google algorithms have evolved to really zero in on the most relevant results, so they give out customized results tailored to each user. Google search results these days take into account many factors, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Type of device 📱&lt;/strong&gt; If a user searches using their smartphone, the search results will look different since, &lt;a href="https://developers.google.com/search/mobile-sites/mobile-first-indexing" rel="noopener noreferrer"&gt;starting in 2015&lt;/a&gt;, Google prefers showing mobile-optimized web pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Registration 🔒&lt;/strong&gt; If a Google user is logged into their account, what they see on SERPs will be aligned with their history and user behavior, provided that's allowed within their data-related settings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Browser history 📖&lt;/strong&gt; If a user rarely empties their browser cache, Google will include that information concerning previous search queries with cookies and adjust the results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Location 📍&lt;/strong&gt; If the geolocalization option is activated, Google aligns the SERPs with the user's location. That's why search results for the &lt;em&gt;sushi takeaway&lt;/em&gt; query in Prague will be different from those in Los Angeles. If we're talking about local search, the results will be a combination of data from Google Search and Google Maps.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Just look at how differently Google shows the results for&lt;/em&gt;&lt;/strong&gt; hot air balloon &lt;strong&gt;&lt;em&gt;for users in Australia and Ukraine. Google's algorithm is highly adaptable to location, browser history, and device type.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What about the official Google Search API?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;That's a funny question. Google doesn't provide its own SERP API for web search - so Google doesn't make it that easy to extract data from Google at scale. Moreover, only a limited subset of information available on any search results page can be provided to you via Google services such as &lt;a href="https://ads.google.com/" rel="noopener noreferrer"&gt;Google Ads&lt;/a&gt; or &lt;a href="https://analytics.google.com/analytics/" rel="noopener noreferrer"&gt;Google Analytics&lt;/a&gt;. The two official methods suggested by Google for getting data are Google Custom Search API (&lt;a href="https://developers.google.com/search/blog/2020/12/search-console-api-updates" rel="noopener noreferrer"&gt;deprecated in April 2018&lt;/a&gt;) and scraping by &lt;a href="https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app" rel="noopener noreferrer"&gt;URLFetch method&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡If you're interested in the Google APIs topic in more depth, see our quick guide through Google APIs: &lt;a href="https://blog.apify.com/top-google-search-api/" rel="noopener noreferrer"&gt;&lt;strong&gt;Top Google search APIs in 2022&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How do you scrape a search engine?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So there's a lack of a working solution from Google, a demand to search results objectively, and lots of manual work ahead. The solution to these issues is an automated crawler that is simple enough to use and complex enough to scrape such a massive website as Google. In other words, an alternative SERP API - that's a lot of Caps, but essentially it's a program that will automatically collect data from Google SERP for you to analyze and use. This is precisely what our &lt;a href="https://apify.com/apify/google-search-scraper" rel="noopener noreferrer"&gt;Google Search Result Scraper&lt;/a&gt; is created for.&lt;/p&gt;

&lt;p&gt;Our SERP API supports the extraction of all data on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;organic and paid results 🔍&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ads 🛍&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;queries &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;People Also Ask 🙋&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;prices 🏷&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;reviews &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need additional attributes, you can also include a short snippet of JavaScript code to extract additional attributes from the HTML. But for now, you can try it out for free on our platform.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://apify.com/zuzka/easy-google-scraper" rel="noopener noreferrer"&gt;😉 &lt;strong&gt;If you want a simpler version of Google search results scraper, we have a great alternative for you: Fast Google Search Scraper&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🔍 How to scrape Google search pages&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that we've covered all the aspects and reasons for scraping Google let's get started with the tutorial. Promise it won't take long :), but if you would prefer a short video tutorial, we have one for you right here 📼:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/eQoO3Wh9JWM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How to scrape data from Google search pages&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1. Go to Google Search Results Scraper&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Go to the &lt;a href="https://apify.com/apify/google-search-scraper" rel="noopener noreferrer"&gt;scraper's page&lt;/a&gt;, and click the &lt;strong&gt;Try for free&lt;/strong&gt; button. You will be redirected to Apify Console, which is your workspace to run tasks for your scrapers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fv6ijkqn3zrn6dur9uh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0fv6ijkqn3zrn6dur9uh.png" alt="Google Search Results Scraper's page on Apify Store" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Google Search Results Scraper's page on Apify Store&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are not signed in, you'll find yourself on the sign-up page. &lt;a href="https://my.apify.com/sign-in" rel="noopener noreferrer"&gt;Sign up&lt;/a&gt; using your email account, Google, or GitHub - no credit card required. You will be redirected to the scraper's page on your &lt;a href="https://console.apify.com/" rel="noopener noreferrer"&gt;Apify Console&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbko588lhyn3euec59is6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbko588lhyn3euec59is6.png" alt="Log in or sign up with Google, GitHub, or your email address" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Log in or sign up with Google, GitHub, or your email address&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2. Insert the keyword you want to scrape&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now fill in the input fields. You can provide keywords or Google Search URLs as many as you want. Let's see what Google data we'll get for &lt;em&gt;hot air balloon.&lt;/em&gt; We can use either a search URL or just the keyword; either will work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5q36o9g4l7u3y5oad9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5q36o9g4l7u3y5oad9w.png" alt="Google Search Results Scraper on Apify Console - typing in the search query" width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Google Search Results Scraper on Apify Console - typing in the search query&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3. Choose the number of pages for extraction&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now set how many Google pages you want to scrape and how many results you want to see on each page. So if you are interested in the first 2 pages and 50 results on each, then you'll scrape 100 pages in total. But so is true if you will set the scraper for the first 5 pages and 20 results on each.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fseufqhhkkpw6xu9y07aj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fseufqhhkkpw6xu9y07aj.jpg" alt="Choose the number of results and Google pages to scrape" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Choose the number of results and Google pages to scrape&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Note that Google will always show you that it has found a gazillion results for almost any query. But in reality, the number of found pages rarely exceeds a few thousand 🤥 This is why it's unlikely that you will find a gazillion pages in your scraped run. You can check it yourself if you set &lt;strong&gt;Results per page&lt;/strong&gt; to max on your &lt;a href="https://www.google.com/preferences?hl=en" rel="noopener noreferrer"&gt;Google account&lt;/a&gt; settings and see how the &lt;em&gt;000000&lt;/em&gt; part of Google pages shrinks to just a few.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 4. Set up country domain and language of search&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Last but not least - where are we searching? This is your time to specify the domain or country + the language. You can mix&amp;amp;match them as you like (for instance, find all French-speaking results in Canadian Google), but we're going to go with Czech-in-Czech.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsdbgbk33pv4ld35kpqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsdbgbk33pv4ld35kpqy.png" alt="Set up country and language of search. We're going to go for Czech Google in the Czech language 🇨🇿" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set up country and language of search. We're going to go for Czech Google in the Czech language 🇨🇿&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 5. Collect your data extracted from Google search&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once you are all set, click the &lt;strong&gt;Start&lt;/strong&gt; button. Notice that your task will change its status to &lt;em&gt;Running&lt;/em&gt;, so wait for the scraper's run to finish. It will be just a minute before you see the status switch to &lt;em&gt;Succeeded&lt;/em&gt;. In our case - 13 seconds, wow! 🚀&lt;/p&gt;

&lt;p&gt;Note that we've only got &lt;strong&gt;4 results&lt;/strong&gt; which only means the scraper finished extracting data from the Google pages just as we've asked it. &lt;strong&gt;The actual number of results is 100&lt;/strong&gt; because we've decided to scrape 2 pages with 50 results each (see &lt;strong&gt;Step 3&lt;/strong&gt; ). You can view all results, only organic results or only paid results. You can also preview them as a table or in JSON.&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;After Google Scraper has finished extracting search data, you can preview the results: all, organic and paid.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also preview the data before downloading it by clicking the &lt;em&gt;Preview in another tab&lt;/em&gt; 👁 button or viewing it in a new tab if the dataset is too large.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Step 6. View and download your Google data&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once you're ready to download Google data, move to the &lt;strong&gt;Export&lt;/strong&gt; button to see the results of your scraping. Now you can download your scraped data in many formats, including HTML table, JSON, CSV, Excel, XML, and RSS feed.&lt;/p&gt;

&lt;p&gt;You can choose to download only paid results, only organic results or all of them. Before downloading, you can also narrow down your dataset to a few specific fields that you want to keep or discard. Last option: getting your results &lt;a href="https://apify.com/apify/google-search-scraper/api/client/nodejs" rel="noopener noreferrer"&gt;via an API&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;View and download your data in different formats&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🛡 Do I need proxies for scraping Google SERPs?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Yes. Apify has proxies designed specifically for SERPs. Our &lt;a href="https://apify.com/proxy" rel="noopener noreferrer"&gt;SERP proxies&lt;/a&gt; will make your scraping much faster, and you'll be able to dynamically switch between countries so that you can get search information from any location. If you sign up for a free Apify account, you get a 30-day free trial of our SERP proxy service.&lt;/p&gt;

&lt;p&gt;Now that you're all ready go ahead and start your &lt;a href="https://apify.com/pricing" rel="noopener noreferrer"&gt;first month&lt;/a&gt; with Apify by using our &lt;a href="https://apify.com/apify/google-search-scraper" rel="noopener noreferrer"&gt;Google Search Scraper&lt;/a&gt;. If you need to scrape other parts of the Google giant, check out our other Google scrapers at &lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;Apify Store&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What are other tools for scraping Google services?&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;👁 &lt;a href="https://apify.com/alexey/google-lens" rel="noopener noreferrer"&gt;Google Lens Actor&lt;/a&gt;
&lt;/th&gt;
&lt;th&gt;📍 &lt;a href="https://apify.com/compass/crawler-google-places" rel="noopener noreferrer"&gt;Google Maps Scraper&lt;/a&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;🔍 &lt;a href="https://apify.com/hooli/google-trending-searches" rel="noopener noreferrer"&gt;Google Trending Searches&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://apify.com/emastra/google-shopping-scraper" rel="noopener noreferrer"&gt;🛍 Google Shopping Scraper&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;📈 &lt;a href="https://apify.com/emastra/google-trends-scraper" rel="noopener noreferrer"&gt;Google Trends Scraper&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;⭐️ &lt;a href="https://apify.com/compass/google-maps-reviews-scraper" rel="noopener noreferrer"&gt;Google Maps Reviews Scraper&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;📩📍 &lt;a href="https://apify.com/lukaskrivka/google-maps-with-contact-details" rel="noopener noreferrer"&gt;Google Maps Email Extractor&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;🤟 &lt;a href="https://apify.com/hamza.alwan/google-datasets-translator" rel="noopener noreferrer"&gt;Google Datasets Translator&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>google</category>
      <category>seo</category>
      <category>tutorial</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>AIOps vs. MLOps</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Wed, 08 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/aiops-vs-mlops-49f2</link>
      <guid>https://forem.com/apify/aiops-vs-mlops-49f2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hi, we're Apify, a full-stack&lt;/strong&gt; &lt;a href="https://apify.com/web-scraping" rel="noopener noreferrer"&gt;&lt;strong&gt;web scraping&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and browser automation platform. This article about AIOps vs. MLOps was inspired by our work on getting&lt;/strong&gt; &lt;a href="https://apify.it/data-for-ai" rel="noopener noreferrer"&gt;&lt;strong&gt;better data for AI&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;AIOps and MLOps are not synonymous&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Its commonplace to mistakenly use artificial intelligence (AI) and machine learning (ML) interchangeably. Thankfully, the same is not true of AIOps and MLOps. Theyre two distinct approaches in the field of IT and data operations, each serving unique purposes.&lt;/p&gt;

&lt;p&gt;I already covered Artificial Intelligence for IT Operations in &lt;a href="https://blog.apify.com/what-is-aiops/" rel="noopener noreferrer"&gt;What is AIOps?&lt;/a&gt; and Machine Learning Operations in &lt;a href="https://blog.apify.com/what-is-mlops/" rel="noopener noreferrer"&gt;What is MLOps?&lt;/a&gt; So, what we'll do here is hone in on the differences and explain when you need the one and when you need the other. In the end, well look at how and why you might combine them.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is AIOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AIOps&lt;/strong&gt; refers to the application of AI and machine learning techniques to enhance and automate IT operations. Its primary goal is to improve the management and monitoring of complex IT environments by analyzing data from various sources to provide actionable insights and predictive capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why use AIOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For proactive problem resolution:&lt;/strong&gt; To detect and predict issues before they impact users and allow for quicker problem resolution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For automation:&lt;/strong&gt; To automate routine tasks and responses and reduce the workload on IT staff.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For enhanced visibility:&lt;/strong&gt; To provide a holistic view of the entire IT infrastructure and identify bottlenecks and areas for improvement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For reduced downtime:&lt;/strong&gt; To predict and prevent outages so as to minimize downtime for systems and applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For cost optimization:&lt;/strong&gt; To help optimize resource allocation and reduce unnecessary spending.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is MLOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;MLOps&lt;/strong&gt; , on the other hand, is a set of practices and tools aimed at streamlining the deployment, monitoring, and management of machine learning models in production environments. It focuses on the operationalization of ML models and maintaining their reliability over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why use MLOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For reproducibility:&lt;/strong&gt; To ensure that machine learning experiments are reproducible and that models are auditable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For scalability:&lt;/strong&gt; To facilitate the scaling of ML models to handle large datasets and increased workloads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For model governance:&lt;/strong&gt; To provide tools for tracking model versions, lineage, and compliance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;For reliability:&lt;/strong&gt; To maintain model performance over time with automated monitoring and retraining.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h2&gt;
  
  
  &lt;strong&gt;What are the differences between AIOps and MLOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Focus&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AIOps&lt;/strong&gt; focuses on IT operations and infrastructure management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MLOps&lt;/strong&gt; focuses on managing machine learning models and their lifecycle.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Use of AI/ML&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AIOps&lt;/strong&gt; uses AI/ML for monitoring, alerting, and optimizing IT environments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MLOps&lt;/strong&gt; uses AI/ML for model training, deployment, and monitoring.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Primary domain&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AIOps&lt;/strong&gt; is mainly used in the IT and DevOps domain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MLOps&lt;/strong&gt; is primarily used in data science and machine learning projects.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What are the use cases of AIOps and MLOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;AIOps use cases&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Network performance monitoring:&lt;/strong&gt; AIOps can analyze network data to identify anomalies, predict congestion, and optimize network performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Incident management:&lt;/strong&gt; It can automatically classify and prioritize incidents, which reduces response times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Capacity planning:&lt;/strong&gt; It helps in optimizing resource allocation by predicting demand and load patterns.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Root cause analysis:&lt;/strong&gt; It can identify the root causes of problems, which helps IT teams resolve issues faster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt; It detects and responds to security threats by analyzing patterns in log and event data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;MLOps use cases&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Recommendation systems:&lt;/strong&gt; MLOps is used to deploy and maintain recommendation models in applications like e-commerce.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Predictive maintenance:&lt;/strong&gt; It helps deploy predictive maintenance models to minimize equipment downtime in manufacturing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Natural language processing:&lt;/strong&gt; Its used to manage NLP models for chatbots, sentiment analysis, and language translation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Financial forecasting:&lt;/strong&gt; It ensures that predictive models for stock prices or credit risk are up-to-date and reliable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Healthcare diagnostics:&lt;/strong&gt; It's employed to deploy and monitor ML models for disease diagnosis and patient monitoring.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;When to use AIOps and when to use MLOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use AIOps when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You need to optimize and automate IT operations and infrastructure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You want to detect and resolve IT issues proactively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You're dealing with monitoring and managing IT systems and networks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use MLOps when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Youre developing, deploying, and maintaining machine learning models in production.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You need to ensure model reliability and scalability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Youre involved in data science and AI projects where ML models play a central role.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;When can you combine AIOps and MLOps?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Organizations may sometimes combine AIOps and MLOps to enhance their overall operations and derive more value from their AI and ML investments. So, lets end with some examples of how you can integrate these two disciplines.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Automated incident resolution with ML predictions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using AIOps to monitor IT infrastructure for anomalies and incidents continuously&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When an incident is detected, AIOps can trigger an MLOps pipeline to analyze relevant data and predict the root cause. ML models may suggest resolutions or actions for IT teams based on historical data. This combination streamlines incident management and thus reduces resolution time.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Dynamic resource allocation for ML workloads&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using AIOps to monitor resource utilization in data centers or cloud environments&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AIOps may trigger an MLOps process when resource constraints or performance issues are detected. ML models are able to predict resource requirements for upcoming machine-learning tasks based on historical patterns. Resources can be dynamically allocated to meet these requirements to optimize cost and performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Security threat detection and response&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using AIOps to monitor logs, network traffic, and system behavior for security anomalies&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AIOPs can trigger an MLOps pipeline when there's suspicious activity. ML models analyze the detected anomalies to determine if they represent real threats. If a threat is confirmed, automated responses or alerts can mitigate the risk.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Optimizing ML model deployment&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using MLOps to manage the entire ML model lifecycle, from training to deployment&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AIOps is able to monitor the performance of deployed ML models in production environments. If AIOps detects a drop in model accuracy or unusual behavior, it can trigger MLOps to retrain or update the model automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Predictive capacity planning for ML infrastructure&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using AIOps to analyze the utilization and performance of servers, GPUs, and other infrastructure components&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ML models are able to predict future capacity requirements based on historical data and upcoming ML workloads. So, if AIOps identifies capacity constraints or bottlenecks, it could trigger MLOps processes to help scale ML infrastructure efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Anomaly detection in ML model behavior&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using AIOps to monitor the behavior of deployed ML models, such as input data distribution and model output&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MLOps may be triggered by AIOps when deviations from expected behavior are detected. The ML models analyze the anomalies to identify potential issues with data quality, model drift, or external factors.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cost optimization for ML workloads&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using AIOps to track the costs associated with IT resources used for ML workloads&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AIOPs can trigger MLOps processes to analyze cost data in relation to model performance and business objectives. ML models are able to make recommendations for optimizing resource allocation to achieve cost-efficiency without compromising performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;AIOps and MLOps are different but not mutually exclusive&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to optimize and automate IT operations and infrastructure, detect and resolve IT issues, or monitor and manage IT systems, AIOps is what you need.&lt;/p&gt;

&lt;p&gt;If youre developing, deploying, and maintaining machine learning models in production and want to ensure model reliability and scalability, you need MLOps.&lt;/p&gt;

&lt;p&gt;That being said, combining the two allows organizations to create a closed-loop system where AI-driven insights from AIOps inform and automate actions within MLOps. This ensures both efficient IT operations and the reliability of machine learning applications.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Whichever one you want to use, you cant build an AIOps or MLOps solution without data. Both solutions begin with data collection, aka&lt;/em&gt; &lt;a href="https://apify.com/web-scraping" rel="noopener noreferrer"&gt;&lt;em&gt;web scraping&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. If you need a web scraping platform for data acquisition, Apify provides the tools and infrastructure you need to harvest data from any website, including&lt;/em&gt; &lt;a href="https://apify.com/data-for-generative-ai" rel="noopener noreferrer"&gt;&lt;em&gt;scrapers and integrations for collecting data for AI and machine learning&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>A guide to data collection for training computer vision models</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Tue, 07 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/a-guide-to-data-collection-for-training-computer-vision-models-3bf0</link>
      <guid>https://forem.com/apify/a-guide-to-data-collection-for-training-computer-vision-models-3bf0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hi, we're Apify, a full-stack&lt;/strong&gt; &lt;a href="https://apify.com/web-scraping" rel="noopener noreferrer"&gt;&lt;strong&gt;web scraping&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and browser automation platform. This article about computer vision was inspired by our work on getting&lt;/strong&gt; &lt;a href="https://apify.it/data-for-ai" rel="noopener noreferrer"&gt;&lt;strong&gt;better data for AI&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is computer vision?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Have you ever used Google Translate by pointing your smartphone at a sign in a foreign language to get an almost immediate translation of it? I have, and I thank computer vision for it every time.&lt;/p&gt;

&lt;p&gt;You've heard of self-driving cars, right? Computer vision is behind those, too.&lt;/p&gt;

&lt;p&gt;What about face detection? Computer vision again.&lt;/p&gt;

&lt;p&gt;The history of computer vision goes back to 1959 - almost as far back as AI itself. It's a field of machine learning that helps computers see the world around them. It involves developing algorithms, techniques, and systems that allow computers to analyze and extract meaning from images, videos, and other visual data.&lt;/p&gt;

&lt;p&gt;The applications of computer vision are very broad, covering fields as wide-ranging as automotive manufacturing, optical character recognition, and face detection.&lt;/p&gt;

&lt;p&gt;It doesn't look like this field is going to slow down any time soon, either, with the market for computer vision predicted to reach &lt;a href="https://www.alliedmarketresearch.com/computer-vision-market-A12701" rel="noopener noreferrer"&gt;$82.1 billion&lt;/a&gt; by 2032. And with the rise of &lt;a href="https://blog.apify.com/multimodal-ai-what-can-it-do/" rel="noopener noreferrer"&gt;multimodal AI&lt;/a&gt;, computer vision use cases are likely to expand.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Datasets: ground truth for machine learning&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For computer vision to work, AI models require access to datasets that serve as their "ground truth" for learning. The process of collecting data for such datasets is pivotal in the development of efficient computer vision models, as the quality and quantity of the data directly influence their accuracy and performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is meant by ground truth?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;"Ground truth" refers to the correct values or labels used for training and evaluation purposes. It serves as a reference or benchmark against which the performance of an AI model is measured. Ground truth data is critical for &lt;a href="https://blog.apify.com/what-is-data-labeling-in-ai/#labeled-data-and-supervised-learning" rel="noopener noreferrer"&gt;supervised learning&lt;/a&gt;, where models are trained using labeled examples and then assessed for their ability to make accurate predictions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wsvnjkm6uv6zq5xmc2z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wsvnjkm6uv6zq5xmc2z.jpg" alt="Data collection for AI and computer vision" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is data collection in AI and computer vision?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Data collection is a broad term. But in AI, its the process of aggregating relevant data and structuring it into datasets suitable for machine learning. The choice of data type, such as video sequences, frames, photos, or patterns, depends on the specific problem the AI model aims to solve.&lt;/p&gt;

&lt;p&gt;In the domain of computer vision, AI models are trained using image datasets to make predictions related to things such as image classification, object detection, and image segmentation. These image or video datasets must contain meaningful information for training the model to recognize patterns and make predictions based on them.&lt;/p&gt;

&lt;p&gt;For example, in industrial automation, image data is collected to identify specific part defects. Therefore, cameras capture footage from assembly lines to create video or photo images, which form the dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Data sources for computer vision&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Generating a high-quality machine learning dataset requires identifying sources that will be used to train the model. There are two ways of sourcing and collecting image or video data for computer vision tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Public image datasets&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Public machine learning datasets are readily available online and are often open-source and free to use. However, it's important to review the dataset's licensing terms, as some may require payment for commercial projects. Public datasets are suitable for common computer vision tasks but may not be suitable for unique or specific problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Custom datasets&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Custom datasets can be created by collecting data using &lt;a href="https://apify.com/store" rel="noopener noreferrer"&gt;web scrapers&lt;/a&gt;, cameras, and other sensor-equipped devices like mobile phones or webcams. Third-party dataset service providers can assist in collecting data for machine learning tasks, and modern computer vision platforms, such as &lt;a href="https://blog.apify.com/pytorch-vs-tensorflow/" rel="noopener noreferrer"&gt;TensorFlow or PyTorch&lt;/a&gt;, host datasets for AI model deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Image annotation and data labeling&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Once data is collected, the next step is image annotation and &lt;a href="https://blog.apify.com/what-is-data-labeling-in-ai/" rel="noopener noreferrer"&gt;data labeling&lt;/a&gt;, where humans manually provide information about the ground truth within the data. This involves indicating the location and characteristics of objects that the AI model should learn to recognize. For example, training a deep learning model to detect giraffes would involve annotating each image or video frame with bounding boxes around the giraffes linked to the label "giraffe." The trained model can then identify giraffes in new images.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Data preparation and characteristics of image data&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Most computer vision models are trained on datasets comprising hundreds or thousands of images. The quality of these images is crucial to the AI model's ability to classify or predict outcomes accurately. There are several key characteristics that can help identify a good image dataset:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quality:&lt;/strong&gt; Images should be detailed enough for the AI model to identify and locate target objects effectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Variety:&lt;/strong&gt; Diverse images in the dataset improve the model's performance in various scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quantity:&lt;/strong&gt; More data is generally better, as training on a large, accurately labeled dataset increases the model's chances of making accurate predictions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Density:&lt;/strong&gt; The density of objects within the images also matters, as more data improves the model's efficiency.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Video data collection&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While computer vision models are predominantly trained on image datasets, certain applications, like video classification, motion detection, and human activity recognition, require video data. Videos are essentially sequences of images, and the process of collecting video data involves identifying sources, scraping video content, recording video files, extracting frames, and preprocessing the data for machine learning.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The best way to collect image and video data&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To train computer vision models, you need vast amounts of data. The go-to solution for collecting real-time data at scale for computer vision and other AI applications is &lt;a href="https://apify.com/web-scraping" rel="noopener noreferrer"&gt;web scraping&lt;/a&gt;. This is a method of retrieving unstructured data from websites and converting it into a structured format so machines can process it. One way to go about this is to build your own custom scrapers (you can learn how in these &lt;a href="https://docs.apify.com/academy" rel="noopener noreferrer"&gt;free web scraping courses&lt;/a&gt;). Another option is to use pre-built scraping and automation tools for extracting image and video data from the web. Here are five options for starters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apify.com/lukaskrivka/images-download-upload" rel="noopener noreferrer"&gt;&lt;strong&gt;Dataset Image Downloader &amp;amp; Uploader&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apify.com/m0uka/bulk-image-downloader" rel="noopener noreferrer"&gt;&lt;strong&gt;Bulk Image Downloader&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apify.com/alexey/google-lens" rel="noopener noreferrer"&gt;&lt;strong&gt;Google Lens (API alternative)&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apify.com/streamers/youtube-scraper" rel="noopener noreferrer"&gt;&lt;strong&gt;YouTube Scraper&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apify.com/clockworks/tiktok-scraper" rel="noopener noreferrer"&gt;&lt;strong&gt;TikTok Scraper&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The challenges of web scraping for computer vision&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Getting blocked&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anyone who has done large-scale &lt;a href="https://blog.apify.com/web-data-extraction/" rel="noopener noreferrer"&gt;data extraction&lt;/a&gt; knows that the biggest challenge for web scraping is &lt;a href="https://blog.apify.com/crawl-without-getting-blocked/" rel="noopener noreferrer"&gt;getting blocked&lt;/a&gt; by anti-bot protections.&lt;/p&gt;

&lt;p&gt;To deal with these and other challenges, you don't just need a web scraper but infrastructure that sets you up to &lt;a href="https://crawlee.dev/" rel="noopener noreferrer"&gt;scrape successfully at scale&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Unclean data&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another challenge, particularly in the field of computer vision, where high-quality images are required, is data cleanliness.&lt;/p&gt;

&lt;p&gt;The web is full of low-quality images, videos, and audio. So you not only need to perform web scraping, but you also need to &lt;a href="https://blog.apify.com/webscraping-ai-data-for-llms/" rel="noopener noreferrer"&gt;clean and process web data to feed AI models&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At Apify, we're well aware of these challenges and have a lot of experience in dealing with them. So, if you want a reliable platform to create your own web scrapers for computer vision models, Apify provides the infrastructure you need. If you prefer a ready-made scraper designed to handle the complexities of a particular website, there's a range of &lt;a href="https://apify.com/data-for-generative-ai" rel="noopener noreferrer"&gt;web scraping and automation tools for AI&lt;/a&gt; available in &lt;a href="https://apify.com/store/categories/ai" rel="noopener noreferrer"&gt;Apify Store&lt;/a&gt;, where developers publish the micro-apps (Actors) they've created for web scraping and automation projects.&lt;/p&gt;

&lt;p&gt;Take your pick!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>dataextraction</category>
    </item>
    <item>
      <title>What are embeddings in AI?</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Mon, 06 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/what-are-embeddings-in-ai-44g7</link>
      <guid>https://forem.com/apify/what-are-embeddings-in-ai-44g7</guid>
      <description>&lt;p&gt;&lt;strong&gt;Apify is all about collecting the right data at scale in the most efficient possible way. So if you need a&lt;/strong&gt; &lt;a href="https://apify.it/data-for-ai" rel="noopener noreferrer"&gt;&lt;strong&gt;web scraping platform&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;to extract large volumes of real-time web data for embeddings and other AI solutions, your project begins with Apify.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is an embedding?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine you're in a bar with a couple of your fellow programming buddies.&lt;/p&gt;

&lt;p&gt;You're huddled together in the corner, geeking out over programming stuff. Over in the other corner is a group of loud, thuggish football fans, annoying everyone with their obnoxious behavior. Meanwhile, all the pretty girls are strutting their stuff on the dance floor, having a good time.&lt;/p&gt;

&lt;p&gt;Notice how different people in this one space are grouped together based on similarities and shared interests.&lt;/p&gt;

&lt;p&gt;In AI, embeddings work the same way. They group similar features in virtually any data type.&lt;/p&gt;

&lt;p&gt;Embeddings are a way to represent data points (like words or even users) in a mathematical space, often multi-dimensional. These embeddings are generated in such a way that similar items are closer together while dissimilar items are farther apart, much like in the bar.&lt;/p&gt;

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

&lt;p&gt;Embeddings are a way to represent data points in a mathematical, multi-dimensional space. An embedding is a relatively low-dimensional space into which you can translate high-dimensional vectors.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Applications of embeddings&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Recommendation systems&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You've probably watched a few movies on a streaming platform at some point in your life. Whenever you do this, the system tries to understand your taste by placing you in a certain position within its "taste space." Based on your position (and the position of movies you liked), it recommends other movies that are close by in this space.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Search engines&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When you type a query, the search engine translates your words into their embedding space and fetches documents that are semantically closer to your query. The closer the semantic relationship, the more likely it is that it's relevant to your search.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Text generation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Embeddings also help in understanding the context of words. If a language model wants to generate a sentence following "The king and the...", it would look at the proximity of words to "king" in the embedding space to predict the next word. That's pretty much how LLMs like ChatGPT work.&lt;/p&gt;

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

&lt;p&gt;Large language models don't understand text, only numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Word embeddings: why are they important for LLMs?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Despite the widespread (mis)use of the term 'AI' for large language models, LLMs are not intelligent. Machines, by their nature, don't understand text. They understand numbers (yet LLMs suck at math: go figure!). An NLP task, whether it's sentiment analysis, machine translation, or document classification, needs numerical data.&lt;/p&gt;

&lt;p&gt;Word embeddings convert words into numbers, but not just any numbers. These numbers (or vectors) capture the semantics, or the meaning, of a word in relation to other words in a given dataset. A well-trained set of word embeddings will place words with similar meanings or contexts close to each other in this multi-dimensional space. The word "king", for example, might be close to "queen" and "monarch", but farther from "apple" or "car". This is what is called semantic relationships.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://blog.apify.com/nlp-techniques/" rel="noopener noreferrer"&gt;&lt;strong&gt;Learn more about NLP in the context of LLMs&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Semantic relationships&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When we say "semantic relationships," we mean the connections between words that have similar meanings or associations.&lt;/p&gt;

&lt;p&gt;Let's continue with the monarch example: consider the words "king," "man," "queen," and "woman." These words have relationships based on gender and monarchy. Good word embeddings can detect these relationships. They can tell us that the difference between "king" and "man" is similar to the difference between "queen" and "woman." In other words, embeddings can mathematically capture the idea that kings and queens are associated with their respective genders.&lt;/p&gt;

&lt;p&gt;This is super useful in various language tasks because it allows computers to recognize not just individual words but also how words relate to each other in meaning.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Dimensionality&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;While a word can be represented as a one-hot encoded vector of the size of the entire vocabulary, embeddings compress this representation into a dense vector of much smaller dimensions.&lt;/p&gt;

&lt;p&gt;Initially, each word is like a huge switchboard with as many switches as there are words in the entire language - it's gigantic! If we have 100,000 words in our vocabulary, that's 100,000 switches for each word. This is what we call a "one-hot encoded vector".&lt;/p&gt;

&lt;p&gt;Now, think about the mess and inefficiency of handling these giant "switchboards". It's not only impractical but also computationally heavy. This is where dimensionality comes into play. We can make things more manageable.&lt;/p&gt;

&lt;p&gt;Word embeddings are like smart compressors. They take each word's "switchboard" and squeeze it down into a much smaller size, typically between 50 to 300 "switches" (dimensions) instead of tens of thousands.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Contextual information&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Words don't live in isolation; they depend on the words around them to convey their full meaning. Think of a word like "bank." Depending on the context, it could mean a financial institution or the side of a river. Understanding these contextual nuances is vital.&lt;/p&gt;

&lt;p&gt;Modern word embeddings, especially contextual ones, can grasp the meaning of a word based on the words that surround it in a sentence or a paragraph.&lt;/p&gt;

&lt;p&gt;For instance, if you see the word "bank" in a sentence like "I deposited money in the bank," a contextual embedding knows it's talking about a financial institution. But if you see "I sat by the bank," it understands that it's referring to the side of a river. This ability to consider context makes embeddings incredibly powerful for tasks like language comprehension, translation, and text generation because they capture the subtleties and nuances of meaning that words carry in different situations.&lt;/p&gt;

&lt;p&gt;These contextual embeddings are the reason LLMs can understand the subtleties of language and accurately interpret the meaning of words in different sentences.&lt;/p&gt;

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

&lt;p&gt;Large language models produce &lt;em&gt;contextual embeddings&lt;/em&gt;. The embedding for a word may be different based on its surrounding words and context.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to create embeddings (tools and methods)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that we've established the necessity of embeddings, the question naturally arises: how on earth do you generate them?&lt;/p&gt;

&lt;p&gt;Fortunately, there's a range of tools, methods, libraries, and platforms out there for creating embeddings. Here are some of the most popular, together with some of the features they offer:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Word2Vec&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.tensorflow.org/text/tutorials/word2vec" rel="noopener noreferrer"&gt;Word2Vec&lt;/a&gt; is a popular method developed by Google that uses neural networks to learn word representations. It can capture semantic relationships between words.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Continuous Bag of Words (CBOW) &amp;amp; Skip-Gram: two architectures to produce a distributed representation of words.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Captures semantic relationships. For instance, the vector math "King" - "Man" + "Woman" might get you close to "Queen".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generates a fixed-size dense vector for each word.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;GloVe (Global Vectors for Word Representation)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Developed by Stanford, &lt;a href="https://nlp.stanford.edu/projects/glove/" rel="noopener noreferrer"&gt;GloVe&lt;/a&gt; is an unsupervised learning algorithm to obtain vector representations for words. It does this by aggregating global word-word co-occurrence statistics from a corpus.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Focuses on word co-occurrence statistics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tries to capture meaning based on how frequently words appear together in large corpora.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generates fixed-size dense vectors for words.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;BERT&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://arxiv.org/abs/1810.04805" rel="noopener noreferrer"&gt;BERT&lt;/a&gt; (Bidirectional Encoder Representations from Transformers) is a deep learning model that generates contextualized word embeddings. Unlike Word2Vec or GloVe, which generate a single word embedding for each word, this model produces embeddings that consider the context in which a word appears.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Contextual embeddings that represent words based on their meaning in a sentence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deep bidirectional transformer architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can handle polysemy (words with multiple meanings).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Hugging Face&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://huggingface.co/" rel="noopener noreferrer"&gt;Hugging Face&lt;/a&gt; is a wildly popular deep learning library that offers a wide array of pre-trained models for NLP tasks, from BERT and GPT-2 to newer models like T5 and BART.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Comes with tokenizers for different models to ensure that text is preprocessed in a manner consistent with the model's original training data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;While offering pre-trained models, the library is designed to fine-tune these models on custom datasets easily.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides out-of-the-box solutions for tasks like text classification, named entity recognition, and translation, simplifying the process for developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Built on both TensorFlow and PyTorch, which gives users the freedom to choose their preferred framework.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://blog.apify.com/how-to-use-hugging-face-transformers-pipelines/" rel="noopener noreferrer"&gt;&lt;strong&gt;Learn more about Hugging Face in this introduction to transformers and pipelines&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;TensorFlow&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Developed by Google, &lt;a href="https://www.tensorflow.org/" rel="noopener noreferrer"&gt;TensorFlow&lt;/a&gt; is designed to provide a flexible platform for building and deploying ML models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Supports training on multiple GPUs and TPUs, which enables faster computations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Allows for more intuitive operations and debugging, behaving more like standard Python operations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An integrated visualization tool to monitor the training process, visualize model architecture, and more.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://blog.apify.com/pytorch-vs-tensorflow/" rel="noopener noreferrer"&gt;&lt;strong&gt;Learn more about TensorFlow in this PyTorch and TensorFlow comparison&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Keras&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://keras.io/" rel="noopener noreferrer"&gt;Keras&lt;/a&gt; acts as an interface for TensorFlow, which makes it simpler to develop deep learning models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Comes with an integrated &lt;code&gt;Embedding&lt;/code&gt; layer, which simplifies the process of creating word embeddings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Allows you to use pre-trained embeddings or train them from scratch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Converts tokenized text to dense vectors of fixed size.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides sequential and functional APIs for building complex architectures.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Offers various pre-trained models for tasks like classification, segmentation, etc., which can be easily imported and fine-tuned.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://blog.apify.com/deep-learning-with-keras/" rel="noopener noreferrer"&gt;&lt;strong&gt;Learn more about Keras&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Gensim&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A Python library specialized for topic modeling and document similarity analysis, &lt;a href="https://pypi.org/project/gensim/" rel="noopener noreferrer"&gt;Gensim&lt;/a&gt; provides tools for working with Word2Vec and other embedding models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Designed to work with large text corpora without consuming vast memory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports Word2Vec, FastText, and other popular embedding algorithms out of the box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Known for its implementation of the Latent Dirichlet Allocation (LDA) algorithm for topic modeling.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides functionalities to compute document similarities based on their semantic meanings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Uses a dictionary to manage and map tokens to their IDs, which can be updated without having to recompute the entire dictionary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports incremental training, meaning you can update your model with new data without starting from scratch.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvnnyqaeol00j5aj5hk2y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvnnyqaeol00j5aj5hk2y.jpg" alt="LLMs use deep neural architectures to generate embeddings." width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LLMs use deep neural architectures to generate embeddings.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How LLMs generate embeddings&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Deep architectures&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;LLMs use deep neural architectures, often transformer-based, which allow them to consider a wide context when generating embeddings. They don't just look at one or two words; they consider the entire context, capturing the complex patterns and relationships in language.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Token and position embeddings&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In models like BERT, each word is initially represented using token embeddings. Think of these as traditional word embeddings, but not static. Then, they add another layer called position embeddings, which indicate the word's position in the sentence. This way, the model knows the order of words and can understand how they relate to each other.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Pre-training and fine-tuning&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Generating embeddings isn't enough, though. AI models need to be pre-trained on the embeddings and fine-tuned.&lt;/p&gt;

&lt;p&gt;For models like BERT, during pre-training, some words in a sentence are masked, which is to say they're hidden, and the model is trained to predict them based on surrounding words. This helps the model learn contextual representations.&lt;/p&gt;

&lt;p&gt;After pre-training on massive datasets, models can be fine-tuned on specific tasks. This allows the embeddings to be further refined for particular applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;But hang on! We forgot the first step!&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Collecting data to create embeddings&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before you can train high-quality embeddings, you'll need to get your paws on vast amounts of data. Then that &lt;a href="https://blog.apify.com/what-is-data-ingestion-for-large-language-models/" rel="noopener noreferrer"&gt;data needs to be ingested&lt;/a&gt; and prepared for machine learning purposes. So the first step to generating and training embeddings is data acquisition and pre-processing. Here's a brief overview of how to go about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collect text data:&lt;/strong&gt; Use open datasets, &lt;a href="https://apify.com/web-scraping" rel="noopener noreferrer"&gt;web scraping&lt;/a&gt;, or access APIs to collect textual data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Clean the data:&lt;/strong&gt; Remove noise and irrelevant information, and perform &lt;a href="https://blog.apify.com/nlp-techniques/#stemming-and-lemmatization" rel="noopener noreferrer"&gt;stemming and lemmatization&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Label the data (if needed):&lt;/strong&gt; While embeddings often use unsupervised learning, &lt;a href="https://blog.apify.com/what-is-data-labeling-in-ai/" rel="noopener noreferrer"&gt;some models might benefit from labeled data&lt;/a&gt;. This can be done manually, via crowdsourcing, or using &lt;a href="https://blog.apify.com/what-is-data-labeling-in-ai/#labeled-and-unlabeled-data-in-semi-supervised-learning" rel="noopener noreferrer"&gt;semi-supervised techniques&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The crucial last step: every embedding needs a home&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So, now we've covered the beginning (data acquisition) and the middle (generating and training embeddings). But the vital final part is storing the embeddings, and that's where vector databases come in.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Storing embeddings in a vector database&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Once embeddings are generated, they can be stored in a &lt;a href="https://blog.apify.com/what-is-a-vector-database/" rel="noopener noreferrer"&gt;vector database&lt;/a&gt; for quick retrieval and similarity search. Because embeddings are high-dimensional vectors, traditional databases aren't optimized for vector search operations. A vector database allows you to find the most similar items quickly, handle literally billions of vectors without sacrificing search speed, and reduces the need for scanning the entire dataset. With a vector database, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Convert embeddings to a suitable format (like numpy arrays).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use database-specific APIs or tools to insert the vectors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Index the database for efficient search.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples of vector databases:&lt;/strong&gt; Pinecone, Milvus, Weaviate, Chroma, FAISS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;You can read more about these and other vector databases in&lt;/strong&gt; &lt;a href="https://blog.apify.com/what-is-pinecone-why-use-it-with-llms/" rel="noopener noreferrer"&gt;&lt;strong&gt;What is Pinecone?&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;a href="https://blog.apify.com/pinecone-alternatives/" rel="noopener noreferrer"&gt;&lt;strong&gt;6-open source Pinecone alternatives&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let's end where we began&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now you know what embeddings are, how they work, and how to generate and use them. But where does Apify fit into all this?&lt;/p&gt;

&lt;p&gt;We gave the game away right at the start:&lt;/p&gt;

&lt;p&gt;Apify is all about collecting the right data at scale in the most efficient possible way. So if you need a &lt;a href="https://apify.com/data-for-generative-ai" rel="noopener noreferrer"&gt;web scraping platform&lt;/a&gt; to extract large volumes of real-time web data to generate and train embeddings and other AI solutions, your project begins with Apify.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>data</category>
    </item>
    <item>
      <title>Python dictionaries: a comprehensive guide for devs</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Sun, 05 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/python-dictionaries-a-comprehensive-guide-for-devs-4841</link>
      <guid>https://forem.com/apify/python-dictionaries-a-comprehensive-guide-for-devs-4841</guid>
      <description>&lt;p&gt;&lt;a href="https://apify.it/platform" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;is all about making the web more programmable. Our&lt;/strong&gt; &lt;a href="https://apify.it/python-sdk" rel="noopener noreferrer"&gt;&lt;strong&gt;SDK for Python&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;is a great toolkit to help simplify the process of making scrapers to collect web data. This tutorial aims to give you a solid understanding of Python dictionaries for storing data.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is a Python dictionary?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python has a variety of built-in data structures that can store different types of data. One such data structure is the Python dictionary, which can store data in the form of &lt;code&gt;key:value&lt;/code&gt; pairs and allows for quick access to values associated with keys. You can think of it like a regular dictionary, where words are keys and their definitions are values.&lt;/p&gt;

&lt;p&gt;In some other languages, the Python dictionary is called a &lt;em&gt;hashtable&lt;/em&gt; because its keys are hashable. Python dictionaries are dynamic and mutable, which means that their data can be changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What are dictionaries used for in Python?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python dictionaries are used to store data in key-value pairs, where each key is unique within a dictionary, while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type, such as strings, numbers, or &lt;a href="https://blog.apify.com/python-tuple-vs-list/" rel="noopener noreferrer"&gt;tuples&lt;/a&gt;. This is because the Python dictionary is implemented internally as a hash table. So, if you hash a mutable object, then change it and hash it again, you will get a different hash.&lt;/p&gt;

&lt;p&gt;Python dictionaries are optimized for fast lookups, making them more efficient than lists for this purpose.&lt;/p&gt;

&lt;p&gt;In Python, the average time complexity of a dictionary key lookup is O(1) because dictionaries are implemented as hash tables, and keys are hashable. On the other hand, the time complexity of a lookup in a list is O(n) on average.&lt;/p&gt;

&lt;p&gt;Using a Python dictionary makes the most sense under the following conditions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If you want to &lt;strong&gt;store data and objects&lt;/strong&gt; using names rather than just index numbers or positions. Use a list if you want to store elements so that you can retrieve them by their index number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you need to &lt;strong&gt;look up data and objects by names&lt;/strong&gt; quickly. Dictionaries are optimized for constant-time lookups.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you need to &lt;strong&gt;store data efficiently and flexibly&lt;/strong&gt;. Dictionaries store unique keys, so if youve got a lot of duplicate data, dictionaries will only store unique data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to use dictionaries in Python&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A dictionary is a group of key-value pairs. Using a dictionary in Python means working with the key-value pairs and performing various operations, such as retrieving data, deleting data, and inserting data.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is a key-value pair?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;key-value pair is a combination of two elements: a key and a value.&lt;/strong&gt; The key in a key-value pair must be immutable, meaning that it cannot be changed. Examples of immutable keys include numbers, strings, and tuples. Values in key-value pairs can be any type of data, including numbers, lists, strings, tuples, and even dictionaries.&lt;/p&gt;

&lt;p&gt;The values can repeat, but the keys must remain unique. You cannot assign multiple values to the same key. However, you can assign a list of values as a single value.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How to create a dictionary?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To create a dictionary in Python, you can use curly braces &lt;code&gt;{}&lt;/code&gt; to enclose a sequence of items separated by commas. Each item consists of a key and a value. There are two primary methods for defining a dictionary: using a literal (curly braces) or built-in function (dict()).&lt;/p&gt;

&lt;p&gt;First, lets create an empty dictionary and then fill it with some items.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's fill the dictionary with some data. Suppose weve got integer keys and string values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = {1: "apify", 2: "crawlee"}print(test_dict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is not necessary that all keys be of the same type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = {1: [2, 3, 4], "product": "crawlee"}print(test_dict) # {1: 'apify', 2: 'crawlee'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can create a dictionary by explicitly calling the Python &lt;code&gt;dict()&lt;/code&gt; constructor. Remember, the main usage of the built-in &lt;code&gt;dict()&lt;/code&gt; function is to convert between different data types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = dict({1: "apify", 2: "crawlee"})print(test_dict) # {1: 'apify', 2: 'crawlee'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dictionary can be created by simply passing the key and value to the &lt;code&gt;dict()&lt;/code&gt; constructor, as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = dict(company="apify", product="crawlee")print(test_dict) # {'company': 'apify', 'product': 'crawlee'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A dictionary can also be created by passing a list of tuples to the &lt;code&gt;dict()&lt;/code&gt; constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = dict([(1, [2, 3, 4]), ("product", "apify")])print(test_dict) # {1: [2, 3, 4], 'product': 'apify'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can create a dictionary inside another dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nested_dict = { "product1": {"name": "Crawlee", "year": 2019}, "product2": {"name": "Actors", "year": 2022},}print(nested_dict) # {'product1': {'name': 'Crawlee', 'year': 2019}, 'product2': {'name': 'Actors', 'year': 2022}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As discussed earlier, each key in the dictionary should be unique. The last assignment of the key overwrites the previous ones.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict = {1: "apify", 1: "crawlee", 1: "proxy"}print(test_dict) # {1: 'proxy'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Python dictionaries, keys should be hashable (they should be immutable). Thus, mutable data types like lists aren't allowed. Let's try to hash() different data types and see what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Hashing of an integerprint(hash(1))# Hashing of a floatprint(hash(1.2))# Hashing of a stringprint(hash("apify"))# Hashing of a tupleprint(hash((1, 2)))# Hashing of a list# Lists are not hashable, so this will raise a TypeErrorprint(f"Hash of list [1, 2, 3]: {hash([1, 2, 3])}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Example of a code result&lt;/p&gt;

&lt;p&gt;Integers, floats, strings, and tuples are &lt;em&gt;hashable&lt;/em&gt; data types, whereas lists are &lt;em&gt;unhashable&lt;/em&gt; data types.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Accessing values using keys&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To access the value from a Python dictionary using a key, you can use the square bracket notation or the &lt;code&gt;get()&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;To access the value using square bracket notation, place the key inside the square brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test_dict[key]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the following code, we access the values using these keys: "&lt;em&gt;name&lt;/em&gt;" and "&lt;em&gt;products&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"], "active": True,}print(company["name"]) # apifyprint(company["products"]) # ['crawlee', 'actors', 'proxy']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the &lt;code&gt;get()&lt;/code&gt; method to access the dictionary elements. Pass the name of the key as the argument to the method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"], "active": True,}print(company.get("name")) # web scraping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, what if you're searching for the key and the key does not exist in the dictionary? If you use the square bracket notation, the program will throw a &lt;code&gt;KeyError&lt;/code&gt;. However, if you use the &lt;code&gt;get()&lt;/code&gt; method, youll get &lt;code&gt;None&lt;/code&gt; by default, and you can also set the default return value by passing the default values as the second argument. The following examples return "&lt;em&gt;Key not found!&lt;/em&gt;" if the key doesn't exist.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"], "active": True,}print(company.get("founder")) # Noneprint(company.get("founder", "Key not found!")) # Key not found!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;How to modify dictionaries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python dictionaries are mutable, which means you can modify the dictionary items. You can add, update, or remove key-value pairs. Here are some basic operations to modify dictionaries.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Adding and updating key-value pairs&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;There are various ways to add new elements to a dictionary. A common way is to add a new key and assign a value to it using the &lt;code&gt;=&lt;/code&gt; operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"], "active": True,}company["repositories"] = 112print(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;New key and value in code result&lt;/p&gt;

&lt;p&gt;New key-value pairs have been added successfully.&lt;/p&gt;

&lt;p&gt;You can add multiple values to a single key using the &lt;code&gt;=&lt;/code&gt; operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}company["products"] = "crawlee", "actors", "proxy"print(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Code output with multiple values&lt;/p&gt;

&lt;p&gt;New values have been added in the form of a tuple.&lt;/p&gt;

&lt;p&gt;If you would like to add a key without a value, you can put &lt;code&gt;None&lt;/code&gt; instead of the value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}company["price"] = Noneprint(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Example of code result without a value&lt;/p&gt;

&lt;p&gt;You can add multiple key-value pairs to an existing dictionary. This is achieved by using the &lt;code&gt;update()&lt;/code&gt; method. If the key is already present in the dictionary, it gets overwritten with the new value. This is the most popular method for adding key-value pairs to the Python dictionary.&lt;/p&gt;

&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Code result with multiple key-value pairs&lt;/p&gt;

&lt;p&gt;One last method involves using the Merge (&lt;code&gt;|&lt;/code&gt;) and Update (&lt;code&gt;|=&lt;/code&gt;) operators. They were introduced in Python 3.9. The merge (&lt;code&gt;|&lt;/code&gt;) operator creates a new dictionary with the keys and values from both of the given dictionaries. You can then assign this newly created dictionary to a new variable.&lt;/p&gt;

&lt;p&gt;The Update (&lt;code&gt;|=&lt;/code&gt;) operator adds the key-value pairs of the second dictionary to the first dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify"}new_dict = {"year": 2015, "solution": "web scraping"}# Merge Operatorresult = company | new_dictprint(result)# Update Operatorcompany |= new_dictprint(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the code result in the &lt;strong&gt;Python (3.9+)&lt;/strong&gt; interpreter:&lt;/p&gt;

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

&lt;p&gt;Example of code result in the Python 3.9+ interpreter&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Removing key-value pairs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The removal of key-value pairs can be done in several ways, which well discuss one by one.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;del&lt;/code&gt; keyword can be used to delete key-value pairs from the dictionary. Just pass the key of the key-value pair that you want to delete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}del company["year"]print(company) # {"name": "apify", "solution": "web scraping", "active": True}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "&lt;em&gt;year&lt;/em&gt;" entry has been deleted from the Python dictionary.&lt;/p&gt;

&lt;p&gt;Another way is to use the &lt;code&gt;pop()&lt;/code&gt; method to delete the key-value pair. The main difference between Pop and Del is &lt;code&gt;pop&lt;/code&gt; will return the popped item, whereas &lt;code&gt;del&lt;/code&gt; will not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}popped_item = company.pop("year")print(popped_item) # 2015print(company) # {'name': 'apify', 'solution': 'web scraping', 'active': True}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't pass the key name, the &lt;code&gt;popitem()&lt;/code&gt; method removes the last item inserted into the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}company.popitem()print(company) # {'name': 'apify', 'year': 2015, 'solution': 'web scraping'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Clearing a dictionary&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to delete the entire dictionary, it would be difficult to use the above methods on every single key to delete all the items. Instead, you can use the &lt;code&gt;del&lt;/code&gt; keyword to delete the entire dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}del companyprint(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But if you try to access the dictionary, youll encounter a &lt;code&gt;NameError&lt;/code&gt; because the dictionary no longer exists.&lt;/p&gt;

&lt;p&gt;A more appropriate method to delete all elements from a dictionary without deleting the dictionary itself is to use the &lt;code&gt;clear()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "active": True,}company.clear()print(company) # Output: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code gives you the empty dictionary as the output. The &lt;code&gt;del&lt;/code&gt; will delete the whole object, and the &lt;code&gt;clear()&lt;/code&gt; method will just clear the content of the dictionary, but the object will remain.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Built-in Python dictionary methods&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python provides a set of built-in methods to make common dictionary operations like adding, deleting, and updating easier. These methods improve code performance and consistency. Some common methods include &lt;code&gt;get()&lt;/code&gt;, &lt;code&gt;keys()&lt;/code&gt;, &lt;code&gt;values()&lt;/code&gt;, &lt;code&gt;items()&lt;/code&gt;, &lt;code&gt;pop()&lt;/code&gt;, and &lt;code&gt;update()&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;get()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;get()&lt;/code&gt; method returns the value for a key if it exists in the dictionary or returns &lt;code&gt;None&lt;/code&gt; if the key does not exist. You can also set a default value, which will be returned when the key does not exist in the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}print(company.get("name"))print(company.get("founder"))print(company.get("founder", "Sorry, key not exist!"))print(company["founder"])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Get method example of code result&lt;/p&gt;

&lt;p&gt;In the above output, when you try to access the key &lt;code&gt;name&lt;/code&gt;, the value &lt;code&gt;apify&lt;/code&gt; is returned. When you try to access the key &lt;code&gt;founder&lt;/code&gt;, which does not exist in the dictionary, the value &lt;code&gt;None&lt;/code&gt; is returned. When you access the key &lt;code&gt;founder&lt;/code&gt; again, the default value that you set to return if the key is not found is returned. Finally, when you try to access the key without using the &lt;code&gt;.get()&lt;/code&gt; method, the program throws an error. This is why the &lt;code&gt;.get()&lt;/code&gt; method is useful.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;keys()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This method returns a list of keys in a dictionary. It returns an iterable object (&lt;code&gt;dict_keys&lt;/code&gt;) that contains a list of all keys in the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}print(company.keys()) # dict_keys(['name', 'year', 'solution', 'products'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Often, this method is used to iterate through each key in the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}for k in company.keys(): print(k)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8pvlmlc2p39ef6rc9kg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8pvlmlc2p39ef6rc9kg1.png" alt="Python dictionary Keys method example of code output" width="712" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keys method example of code output&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;values()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Returns a list of all values in the dictionary. The &lt;code&gt;values()&lt;/code&gt; method returns a &lt;code&gt;dict_values&lt;/code&gt; object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}print(company.values())# Output: dict_values(['apify', 2015, 'web scraping', ['crawlee', 'actors', 'proxy']])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;items()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This method returns a list of key-value pairs as tuples, where the first item in each tuple is the key, and the second item is the value. The returned object is iterable, so this method is primarily used when you want to iterate through the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}print(company.items())# Output: dict_items([('name', 'apify'), ('year', 2015), ('solution', 'web scraping'), ('products', ['crawlee', 'actors', 'proxy'])])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you iterate through the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}for k, v in company.items(): print(k, v)# or for x in company: print(x, company[x])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyj09ao2oyno5upnhy4ut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyj09ao2oyno5upnhy4ut.png" alt="Python dictionary Items method example of code output" width="687" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Items method example of code output&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note that&lt;/strong&gt; when you change the value in the dictionary, the &lt;code&gt;items&lt;/code&gt; object will also be updated to reflect the changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = { "name": "apify", "year": 2015, "solution": "web scraping", "products": ["crawlee", "actors", "proxy"],}pairs = company.items()print(pairs)company["year"] = 2023print(pairs)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftooylk19g145nc7ks2qk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftooylk19g145nc7ks2qk.png" alt="Example of code result with changed value in the dictionary" width="800" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example of code result with changed value in the dictionary&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;pop()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;pop()&lt;/code&gt; method removes a key from a dictionary if it is present and returns its associated value.&lt;/p&gt;

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

&lt;p&gt;Example of code output pop method&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;pop()&lt;/code&gt; method raises an error if the key is not found.&lt;/p&gt;

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

&lt;p&gt;Pop method example of error&lt;/p&gt;

&lt;p&gt;But if you don't want this error to be raised, you can set a default value.&lt;/p&gt;

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

&lt;p&gt;Pop method setting a default value&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;update()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The update() method is useful whenever you want to merge a dictionary with another dictionary or with an iterable of key-value pairs. Let's consider that the dictionary &lt;code&gt;company&lt;/code&gt; will be updated using the entries from the dictionary &lt;code&gt;new_dict&lt;/code&gt;. For each key in &lt;code&gt;new_dict&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If the key is not already present in the &lt;code&gt;company&lt;/code&gt;, the key-value pair from &lt;code&gt;new_dict&lt;/code&gt; will be added to the &lt;code&gt;company&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the key is already present in the &lt;code&gt;company&lt;/code&gt;, the corresponding value in the &lt;code&gt;company&lt;/code&gt; for that key is updated with the value from &lt;code&gt;new_dict&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}new_dict = { "active": True, "solution": "web scraping and automation",}company.update(new_dict)print(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Update method example of code output&lt;/p&gt;

&lt;p&gt;As shown above, the new key &lt;code&gt;active&lt;/code&gt; is added to the &lt;code&gt;company&lt;/code&gt; dictionary, and the &lt;code&gt;solution&lt;/code&gt; key is updated.&lt;/p&gt;

&lt;p&gt;Now, &lt;code&gt;new_dict&lt;/code&gt; can also be specified as a list of tuples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}new_dict = (("active", True), ("solution", "web scraping and automation"))company.update(new_dict)print(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Update method with a list of tuples code result&lt;/p&gt;

&lt;p&gt;Values to be merged can also be specified as a list of arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}new_dict = (("active", True), ("solution", "web scraping and automation"))company.update(active=True, solution="web scraping and automation")print(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9pjvxrv00w1vwy56ydj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9pjvxrv00w1vwy56ydj.png" alt="Update method with values as a list of arguments code output example" width="800" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Update method with values as a list of arguments code output example&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;fromkeys() method&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;fromkeys()&lt;/code&gt; method is used to create a dictionary from a given sequence of keys (which can be a string, tuple, list, etc.) and values. The &lt;code&gt;value&lt;/code&gt; parameter is optional, and if a value is not provided, &lt;code&gt;None&lt;/code&gt; is assigned to the keys. The &lt;code&gt;fromkeys()&lt;/code&gt; method returns a new dictionary with the specified sequence of keys and values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;keys = {"name", "year", "solution"}value = "apify"new = dict.fromkeys(keys, value)print(new) # Output: {'name': 'apify', 'solution': 'apify', 'year': 'apify'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a value is not provided, &lt;code&gt;None&lt;/code&gt; will be assigned as the value to all the keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;keys = {"name", "year", "solution"}new = dict.fromkeys(keys)print(new)# Output: {'year': None, 'solution': None, 'name': None}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's take a look at one more feature provided by &lt;code&gt;fromkeys()&lt;/code&gt;. This time, use a mutable value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;keys = {"name", "year", "solution"}value = ["apify"]new = dict.fromkeys(keys, value)print(new)value.append(2015)print(new)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Fromkeys method code output example&lt;/p&gt;

&lt;p&gt;In the above result, when we update the list value using &lt;code&gt;append&lt;/code&gt;, the keys are assigned with the new updated values. This is because each element is referencing the same memory address.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;copy()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This method returns a copy of the existing dictionary. Note that modifications made to the copied dictionary won't affect the original one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}new_copy = company.copy()print(new_copy)new_copy["name"] = "apify technology"print(company)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm6xyj979nicu8avc1f4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzm6xyj979nicu8avc1f4.png" alt="Python dictionary Copy method example of code output" width="723" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy method example of code output&lt;/p&gt;

&lt;p&gt;In the code, we are trying to modify the name of the &lt;code&gt;new_copy&lt;/code&gt; dictionary, but it does not affect the original dictionary (&lt;code&gt;company&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Iterating over dictionaries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The dictionary allows access to the data in &lt;code&gt;O(1)&lt;/code&gt; time. So, it is important to understand how to iterate over it so that you can access the data youve stored in the dictionary. Three commonly used methods for iterating over dictionaries are &lt;code&gt;keys()&lt;/code&gt;, &lt;code&gt;values()&lt;/code&gt;, and &lt;code&gt;items()&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Using loop with keys()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This method allows you to iterate through all the initialized keys. It returns a view object, which is basically a view of some data. You can iterate over this returned object without any problems. However, if you want to store the list of keys, you need to materialize it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}all_keys = company.keys()print(all_keys) # dict_keys(['name', 'year', 'solution'])# Materializing the keys into a list of keyskeys_list = list(company.keys())print(keys_list) # ['name', 'year', 'solution']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first result is a view object, and the second result is a list of keys because you materialize the view object into a list.&lt;/p&gt;

&lt;p&gt;Now, let's iterate over the dictionary, demonstrating two simple ways.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}for key in company.keys(): print(key, company[key])for key in company: print(key, company[key])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Loop with keys example of code output&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; When using the &lt;code&gt;in&lt;/code&gt; keyword with a dictionary, the dictionary invokes the &lt;code&gt;__iter__ ()&lt;/code&gt; method, which returns an iterator. This iterator is then used to iterate through the keys of the dictionary implicitly.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Using loop with values()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Like the &lt;code&gt;keys()&lt;/code&gt; method, the &lt;code&gt;values()&lt;/code&gt; method also returns a view object that allows you to iterate over the values. Unlike the &lt;code&gt;keys()&lt;/code&gt; method, this method provides only values. So, if you are not concerned about the keys, use this method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}for val in company.values(): print(val)# Output:""""apify2015web scraping"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Using loop with items()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Similar to the previous method, the &lt;code&gt;items()&lt;/code&gt; method also returns a view object, but here you can iterate through the (key, value) pairs instead of iterating through either keys or values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}for item in company.items(): print(item)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Loop with items example of code output&lt;/p&gt;

&lt;p&gt;The above code returns the key-value pairs. Now, to immediately assign both keys and values simultaneously, you can use tuple unpacking and extract them using variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "apify", "year": 2015, "solution": "web scraping"}for key, value in company.items(): print(key, value)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0a0pcb7iyxlwbab6v24j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0a0pcb7iyxlwbab6v24j.png" alt="Loop with items assigning keys and values using variables code result example" width="562" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Loop with items assigning keys and values using variables code result example&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Dictionary comprehensions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;First, let's remind ourselves what comprehension is in Python. It simply means applying a specific kind of operation on each element of an iterable (tuple, list, or dictionary). Dictionary comprehension is similar to list comprehension, but it creates a dictionary instead of a list.&lt;/p&gt;

&lt;p&gt;It is a useful feature that allows us to create dictionaries on a single line concisely and efficiently. The common uses of dictionary comprehension include constructing dictionaries, transforming existing dictionaries, and filtering dictionary content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{key: value for (key, value) in iterable}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose youve got a dictionary that contains the names and money of each person. Suppose you want to transform the dictionary's values, i.e., you want to increment each amount of money by 10 dollars.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;person = {"satyam": 22, "john": 18, "elon": 19}# Dictionary comprehension approachnew_person = {name: money + 10 for name, money in person.items()}print(new_person) # {'satyam': 32, 'john': 28, 'elon': 29}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose you want to filter all the person names whose money is less than 20 dollars.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;person = {"satyam": 22, "john": 18, "elon": 19}new_person = {name: money for name, money in person.items() if money &amp;lt; 20}print(new_person) # {'john': 18, 'elon': 19}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's filter the data by using &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt; with dictionary comprehension. Suppose you want to create a new dictionary where the amount of money less than 20 will get a 20% increase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;person = {"satyam": 22, "john": 18, "elon": 19}new_person = { name: money * 1.2 if money &amp;lt; 20 else money for name, money in person.items()}print(new_person) # {'satyam': 22, 'john': 21.6, 'elon': 22.8}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can perform a lot of operations in one line using dictionary comprehension.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Advanced Python dictionary operations&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python dictionaries allow you to perform various advanced operations, such as handling missing keys using the &lt;code&gt;get()&lt;/code&gt; and &lt;code&gt;setdefault()&lt;/code&gt; methods, merging dictionaries, and working with nested dictionaries. This ultimately provides a lot of flexibility for working with data in a more structured way.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Handling missing keys with get() and setdefault()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Sometimes, users don't know if a key exists in a dictionary, and they try to access it. This can cause an error. There are a few ways to handle missing keys. One way is to use the &lt;code&gt;get()&lt;/code&gt; and &lt;code&gt;setdefault()&lt;/code&gt; methods to set a default value for the key. This way, you don't have to handle the error yourself.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;get()&lt;/code&gt; method returns the associated value if the key is found in the dictionary. Otherwise, it returns the default value (which is &lt;code&gt;None&lt;/code&gt; by default), instead of raising an error. You can also specify a custom default value as the second argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "Apify", "year": 2015, "solution": "web scraping"}# Accessing a key using the get() methodprint(company.get("founder"))# Accessing a key using the get() method with a default valueprint(company.get("founder", "Sorry, key not found!"))# Accessing a key without using the get() methodprint(company["founder"])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Missing keys example of code output&lt;/p&gt;

&lt;p&gt;Another method is &lt;code&gt;setdefault()&lt;/code&gt;. If the key is present in the dictionary, it returns the value of the key. Otherwise, this method inserts a new key with the default value passed as an argument in the method as its value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a dictionary to store person's informationperson = {"name": "Satyam", "age": 21}# If the 'age' key is present, retrieve its value; otherwise, set a default valueage = person.setdefault("age", "Key not found!")# If the 'city' key is not present, set it to the default value "Key not found!"city = person.setdefault("city", "Key not found!")print("Age:", age)print("City:", city)# The dictionary 'person' will be updated as the new key 'city' is addedprint("Updated dictionary:", person)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Using setdefault for missing keys code output example&lt;/p&gt;

&lt;p&gt;In the above code, the &lt;code&gt;age&lt;/code&gt; key is already in the dictionary. We are trying to set the default value for the &lt;code&gt;age&lt;/code&gt; key, but this is impossible. So, the &lt;code&gt;age&lt;/code&gt; value remains the same, which is 21. We are also trying to set the default value for the &lt;code&gt;city&lt;/code&gt; key, which is not in the dictionary. So, the &lt;code&gt;city&lt;/code&gt; value is set to the default value, &lt;code&gt;Key not found&lt;/code&gt;. Now, if you try to access the &lt;code&gt;city&lt;/code&gt; key, the default value will be printed. The dictionary has been updated as the new key &lt;code&gt;city&lt;/code&gt; is added.&lt;/p&gt;

&lt;p&gt;The main difference between &lt;code&gt;get()&lt;/code&gt; and &lt;code&gt;setdefault()&lt;/code&gt; is that &lt;code&gt;get()&lt;/code&gt; only returns the value of the key if it exists in the dictionary, while &lt;code&gt;setdefault()&lt;/code&gt; will set the key to the default value if it does not exist.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Merging dictionaries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Merging of dictionaries happens from right to left (A B). When there is a common key in both dictionaries, the value from the second dictionary overwrites the value in the first dictionary. As shown in the illustration below, key 1 exists in both dictionary A and dictionary B, but the value of key 1 in dictionary B overwrites the value of key 1 in dictionary A. This process occurs from right to left.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.apify.com%2Fcontent%2Fimages%2F2023%2F11%2Fmergingdictionaries--1-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.apify.com%2Fcontent%2Fimages%2F2023%2F11%2Fmergingdictionaries--1-.png" alt="Merging dictionaries" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Merging dictionaries&lt;/p&gt;

&lt;p&gt;Lets understand some ways to merge Python dictionaries.&lt;/p&gt;

&lt;p&gt;From Python version 3.9 onward, we can use the merge (&lt;code&gt;|&lt;/code&gt;) and Update (&lt;code&gt;|=&lt;/code&gt;) operators. The merge (&lt;code&gt;|&lt;/code&gt;) operator creates a new dictionary with the keys and values from both of the given dictionaries. You can then assign this newly created dictionary to a new variable. The Update (&lt;code&gt;|=&lt;/code&gt;) operator adds the key-value pairs of the second dictionary to the first dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict_a = {"name": "apify", "year": 2015, "solution": "web scraping"}dict_b = {"name":"apify tech", "active": True, "repos": 112}# Merge Operatorresult = dict_a | dict_bprint(result)# Update Operatordict_a |= dict_bprint(dict_a)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Merging dictionaries code output example&lt;/p&gt;

&lt;p&gt;Another method is to merge by unpacking both dictionaries using double asterisks (**).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict_a = {"name": "apify", "year": 2015, "solution": "web scraping"}dict_b = {"name":"apify tech", "active": True, "repos": 112}result = { **dict_a,** dict_b}print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Merging dictionaries by unpacking them code result example&lt;/p&gt;

&lt;p&gt;Another way is to copy one of the dictionaries and update it with other dictionaries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dict_a = {"name": "apify", "year": 2015, "solution": "web scraping"}dict_b = {"name":"apify tech", "active": True, "repos": 112}copy_dict_a = dict_a.copy()copy_dict_a.update(dict_b)print(copy_dict_a)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29mfhr6wlc294b4e5knw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29mfhr6wlc294b4e5knw.png" alt="Merging dictionaries by copying one of them code result example" width="800" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Merging dictionaries by copying one of them code result example&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Nested dictionaries&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A nested dictionary is a collection of dictionaries within a single dictionary. In short, a nested dictionary is a dictionary inside another dictionary. Below, we have created a nested dictionary for two companies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;companies = { "Apify": { "founded_year": 2012, "HQ_location": "Prague, Czech Republic", "CEO": "Jan Curn", "products": ["Web Scraping", "Data Extraction", "Automation"], }, "Google": { "founded_year": 1998, "HQ_location": "Mountain View, California", "CEO": "Sundar Pichai", "products": ["Search", "Android", "YouTube"], },}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can access individual items in a nested dictionary by specifying the key within multiple square brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;companies = { "Apify": { "founded_year": 2012, "HQ_location": "Prague, Czech Republic", "CEO": "Jan Curn", "products": ["Web Scraping", "Data Extraction", "Automation"], }, "Google": { "founded_year": 1998, "HQ_location": "Mountain View, California", "CEO": "Sundar Pichai", "products": ["Search", "Android", "YouTube"], },}print(companies["Apify"]["HQ_location"]) # Prague, Czech Republicprint(companies["Apify"]["CEO"]) # Jan Curn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the key is not present, the program will raise an exception. To avoid this exception, you can use the &lt;code&gt;get()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;companies = { "Apify": { "founded_year": 2012, "HQ_location": "Prague, Czech Republic", "CEO": "Jan Curn", "products": ["Web Scraping", "Data Extraction", "Automation"], }, "Google": { "founded_year": 1998, "HQ_location": "Mountain View, California", "CEO": "Sundar Pichai", "products": ["Search", "Android", "YouTube"], },}# Accessing the HQ location of 'Apify'print(companies["Apify"].get("HQ_location")) # Output: Prague, Czech Republic# Attempting to access a non-existent key ('Founder') in 'Apify'print(companies["Apify"].get("Founder")) # Output: None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change the value of a specific item in a nested dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;companies = { "Apify": { "founded_year": 2012, "HQ_location": "Prague, Czech Republic", "CEO": "Jan Curn", "products": ["Web Scraping", "Data Extraction", "Automation"], }, "Google": { "founded_year": 1998, "HQ_location": "Mountain View, California", "CEO": "Sundar Pichai", "products": ["Search", "Android", "YouTube"], },}companies["Apify"]["founded_year"] = 2015companies["Apify"]["CEO"] = "Curn Jan"print(companies)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Nested dictionaries code result example&lt;/p&gt;

&lt;p&gt;You can add or update nested dictionary items. If the key is not present in the dictionary, the key will be added. If the key is already present in the dictionary, its value is replaced by the new one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;companies = { "Apify": { "founded_year": 2012, "HQ_location": "Prague, Czech Republic", "CEO": "Jan Curn", "products": ["Web Scraping", "Data Extraction", "Automation"], }, "Google": { "founded_year": 1998, "HQ_location": "Mountain View, California", "CEO": "Sundar Pichai", "products": ["Search", "Android", "YouTube"], },}# Adding a new company ('Amazon') to the dictionarycompanies["Amazon"] = { "founded_year": 1994, "HQ_location": "Seattle, Washington", "CEO": "Andy Jassy", "products": ["eCommerce", "Amazon Web Services", "Kindle"],}print(companies)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Nested dictionary items code output example&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;del&lt;/code&gt; statement to delete elements from the nested dictionary. In the code below, we are trying to delete the &lt;code&gt;Google&lt;/code&gt; dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;companies = { "Apify": { "founded_year": 2012, "HQ_location": "Prague, Czech Republic", "CEO": "Jan Curn", "products": ["Web Scraping", "Data Extraction", "Automation"], }, "Google": { "founded_year": 1998, "HQ_location": "Mountain View, California", "CEO": "Sundar Pichai", "products": ["Search", "Android", "YouTube"], },}del companies["Google"]print(companies)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code result:&lt;/p&gt;

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

&lt;p&gt;Using del statement code result example&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Real-world applications for Python dictionaries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python dictionary is a very useful data structure and is used in many real-world scenarios because they are easy to use, flexible, and efficient.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Benefits&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ease of use:&lt;/strong&gt; Python dictionary is a powerful data structure that makes it easy to store and retrieve data. They are easy to use, provide quick access to data, and make finding data much easier. With very little code, you can modify dictionaries, add and delete objects, and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexible:&lt;/strong&gt; Python dictionaries are flexible and can store many different types of data, such as numbers, strings, and lists. This makes it easy to access and manipulate the data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Efficiency:&lt;/strong&gt; Python dictionaries use hash tables to store data, which allows them to find the value associated with a key quickly. Python dictionaries take very little space to store data, making them ideal for applications that need to access and manipulate large amounts of data easily. Python dictionary functions like &lt;code&gt;get()&lt;/code&gt; and &lt;code&gt;setdefault()&lt;/code&gt; let you efficiently look up data in a dictionary. Other functions like &lt;code&gt;pop()&lt;/code&gt;, &lt;code&gt;update()&lt;/code&gt;, and &lt;code&gt;clear()&lt;/code&gt; are efficient for manipulating data.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let's take a look at the real-life application where Python dictionaries are used a lot. This example shows how to store student data using a Python dictionary efficiently. You can access the student data without getting an error if the student information is not found. You can also list all the student information and remove specific student details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class StudentDatabase: def __init__ (self): self.students = {} def add_student(self, student_id, name, grade): self.students[student_id] = {"name": name, "grade": grade} def get_student_info(self, student_id): return self.students.get(student_id, None) def list_all_students(self): for student_id, student_info in self.students.items(): print( f"Student ID: {student_id}, Name: {student_info['name']}, Grade: {student_info['grade']}" ) def remove_student(self, student_id): if student_id in self.students: del self.students[student_id] print("Student removed from the database.") else: print("Student not found in the database")def main(): student_manager = StudentDatabase() while True: print("\\nStudent Management Menu:") print("1. Add Student") print("2. Retrieve Student Information") print("3. List All Students") print("4. Remove Student") print("5. Exit") choice = input("Enter your choice: ") if choice == "1": student_id = input("Enter student ID: ") name = input("Enter student name: ") grade = input("Enter student grade: ") student_manager.add_student(student_id, name, grade) print("Student added to the database.") elif choice == "2": student_id = input("Enter student ID to retrieve: ") student = student_manager.get_student_info(student_id) if student: print( f"Student ID: {student_id}, Name: {student['name']}, Grade: {student['grade']}" ) else: print("Student not found in the database.") elif choice == "3": student_manager.list_all_students() elif choice == "4": student_id = input("Enter student ID to remove: ") student_manager.remove_student(student_id) elif choice == "5": break else: print("Invalid choice. Please try again.") print("Goodbye!")if __name__ == " __main__": main()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mik0it4gwb5jb4clnrl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mik0it4gwb5jb4clnrl.png" alt="How to store student data using a Python dictionary code output" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How to store student data using a Python dictionary code output&lt;/p&gt;

&lt;p&gt;Similarly, Python dictionaries can be used in other real-life applications, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Creating a contact book to store all of your contacts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building a user authentication service to store all of your users' data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Best practices for Python dictionaries&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Following best practices can help you get the most out of dictionaries and avoid common pitfalls. The best practices ensure that your code will remain maintainable, reliable, and perform at its best.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Ensuring unique keys&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Keys in a Python dictionary must be unique. If you try to insert a duplicate key, the new value will overwrite the existing one. The most common and straightforward method to ensure unique keys is to check whether the key exists in the dictionary before inserting a new key-value pair. You can use the &lt;code&gt;in&lt;/code&gt; operator for this.&lt;/p&gt;

&lt;p&gt;In the following code, we check if the key exists. If it does not exist, we simply insert it. Otherwise, we handle it accordingly, such as ignoring the new value, replacing the existing value with the new value, or raising an exception.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company = {"name": "Apify", "founded": 2012}key = "solution"# Check if the 'key' exists in the 'company' dictionaryif key not in company: # If it doesn't exist, add the 'key' with the value 'web scraping' company[key] = "web scraping"else: # Handle the case when 'key' already exists in the dictionary (duplicate key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Mutable vs. immutable key types&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Dictionary keys must be of an immutable type, such as integers, floats, strings, tuples, or Booleans. Lists and dictionaries cannot be dictionary keys because they are mutable. However, values can be of any type and used multiple times.&lt;/p&gt;

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

&lt;p&gt;Mutable vs. immutable key types error example&lt;/p&gt;

&lt;p&gt;The output is an Exception, what does &lt;strong&gt;unhashable&lt;/strong&gt; mean?&lt;/p&gt;

&lt;p&gt;It simply means that the Python interpreter is not able to generate a hash for the key given in the dictionary, whose data type is a list. So, the values of a dictionary can be of any type, but the keys must be of an &lt;strong&gt;immutable&lt;/strong&gt; data type.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance considerations&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python dictionaries are an excellent choice for fast lookups, insertions, and deletions. However, some factors may affect their performance.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Use dictionary comprehension when creating dictionaries. Dictionary comprehension is more concise and readable than a loop, and it is also more efficient in some cases, especially for large datasets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flat dictionaries are faster than nested dictionaries. If you want to store nested data, consider using a different data structure, such as a list of dictionaries or a tuple of dictionaries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When initializing a new dictionary, using &lt;code&gt;{}&lt;/code&gt; is more efficient than calling &lt;code&gt;dict()&lt;/code&gt;. With &lt;code&gt;{}&lt;/code&gt;, there are no function call overheads. Calling &lt;code&gt;dict()&lt;/code&gt; requires Python to look up and execute a function, which incurs a slight performance penalty.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Python dictionary in use&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Comparing dictionaries with other Python data structures&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Python dictionary have their own unique characteristics and use cases when compared to other data structures like lists, sets, and tuples.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Differences and similarities with lists, sets, and tuples&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lists&lt;/strong&gt; are the ordered collections of elements that can be modified after creation. Items can be accessed by index, and duplicates are allowed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sets&lt;/strong&gt; are unordered collections of unique elements that cannot be modified after creation. Sets are commonly used for operations such as finding the union, intersection, or difference between sets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tuples&lt;/strong&gt; are immutable ordered collections of elements that cannot be modified after creation. Tuples are often used when you want to ensure that a collection of items remains constant and in a specific order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dictionaries&lt;/strong&gt; are the unordered collections of key-value pairs. The keys must be unique and hashable, and the values can be any type of data. Dictionaries can be modified after creation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;When to use dictionaries over other data structures&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Python dictionaries provide a fast and efficient way to retrieve data by its key in constant time, &lt;code&gt;O(1)&lt;/code&gt;. Dictionaries do not allow duplicate keys, so you can be sure that each key in a dictionary is unique. This makes them an excellent choice for storing large amounts of data in memory.&lt;/p&gt;

&lt;p&gt;When you need to access a specific element in a data structure, dictionaries are much faster than other data structures, such as lists. This is because the runtime for dictionary lookup operations is constant.&lt;/p&gt;

&lt;p&gt;Here is a simple comparison of the runtimes for list and dictionary lookup operations:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;List:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import time# Create a list containing numbers from 0 to 9,999,999number_list = [number for number in range(10**7)]# Measure the time taken to check if '5' is in the liststart_time = time.time()if 5 in number_list: print("5 is in the list")list_runtime = time.time() - start_timeprint(f"\\nList runtime (checking '3' in the list): {list_runtime} seconds.")# Measure the time taken to find the number '9,000,000' in the liststart_time = time.time()for number in number_list: if number == 9000000: breaklist_runtime = time.time() - start_timeprint(f"\\nList runtime (finding '9,000,000' in the list): {list_runtime} seconds.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5xekx4ep5kea6j0hyjc7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5xekx4ep5kea6j0hyjc7.png" alt="Comparison of the runtimes for list. Code output example" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparison of the runtimes for list. Code output example&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dictionary:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import time# Create a dictionary with keys and valuesdictionary_data = {i: i * 2 for i in range(10**7)}# Measure the time taken to check if '5' is a key in the dictionarystart_time = time.time()if 5 in dictionary_data: print("Key '5' is in the dictionary.")dict_runtime = time.time() - start_timeprint( f"\\nDictionary runtime (retrieving the value for key '5'): {dict_runtime:.6f} seconds.")# Measure the time taken to retrieve the value for the key '9,000,000' from the dictionarystart_time = time.time()value = dictionary_data.get(9000000)dict_runtime = time.time() - start_timeprint( f"\\nDictionary runtime (retrieving the value for key '9,000,000'): {dict_runtime:.6f} seconds.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heres the code output:&lt;/p&gt;

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

&lt;p&gt;Example of dictionary runtimes&lt;/p&gt;

&lt;p&gt;Have you noticed that dictionaries perform much better than lists when looking up larger indexes? It took the dictionary almost no time to locate the number, while the list took around 1 second to perform the same operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Wrapping up&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You learned in detail how to create, modify, and delete Python dictionaries, as well as some of the most commonly used dictionary methods and advanced Python dictionary operations. Start using these dictionary methods whenever you see a possibility. Build amazing projects using dictionaries and their methods, keeping best practices in mind.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>data</category>
    </item>
    <item>
      <title>TypeScript utility types: when and how to use them</title>
      <dc:creator>Apify</dc:creator>
      <pubDate>Thu, 02 Nov 2023 23:00:00 +0000</pubDate>
      <link>https://forem.com/apify/typescript-utility-types-when-and-how-to-use-them-1fh2</link>
      <guid>https://forem.com/apify/typescript-utility-types-when-and-how-to-use-them-1fh2</guid>
      <description>&lt;p&gt;&lt;strong&gt;The&lt;/strong&gt; &lt;a href="https://docs.apify.com/sdk/js/docs/guides/type-script-actor" rel="noopener noreferrer"&gt;&lt;strong&gt;Apify SDK supports TypeScript&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;by covering public APIs with type declarations. This allows writing code with auto-completion for TypeScript and JavaScript code alike. This article was written to provide you with a deeper knowledge of TypeScript. But if you want to know more about how it compares with JavaScript for web scraping, you might like to read&lt;/strong&gt; &lt;a href="https://blog.apify.com/typescript-vs-javascript-crawler/" rel="noopener noreferrer"&gt;&lt;strong&gt;TypeScript vs. JavaScript: which to use for web scraping?&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is TypeScript?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;TypeScript is a superset of JavaScript that provides you with the capabilities of static type-checking, enabling you to catch type-related errors during development. One very useful feature of TypeScript is being able to define and manipulate types effectively to write code that is maintainable and reliable.&lt;/p&gt;

&lt;p&gt;Utility types in TypeScript play a significant role in this regard, as they enable you to create new types based on existing ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What are utility types?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Utility types are sets of built-in generic types in TypeScript that allow you to create, manipulate, or create new types by applying specific modifications and transformations to existing types.&lt;/p&gt;

&lt;p&gt;Implementing utility types in your TypeScript project can make working with types more flexible, expressive, and reusable. Declaring your own custom utility types or using TypeScript's built-in utility types are the two approaches to adding utility types to your code base.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;TypeScript built-in utility types&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;There are different built-in utility types that come along with the TypeScript language to make type transformations without you needing to install a library or create a custom type to use them. Lets look at some of them:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1.&lt;/strong&gt; &lt;code&gt;Partial&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;When defined, the partial utility type in TypeScript turns all of a type's properties into optional fields. This allows you to modify the type's fields in part without TypeScript throwing errors.&lt;/p&gt;

&lt;p&gt;For example, say you have &lt;code&gt;User&lt;/code&gt; data in your application and want to update the information of the user. You only want to update specific fields and not the whole data. Using the &lt;code&gt;Partial&lt;/code&gt; utility type, you can transform the data fields of the &lt;code&gt;User&lt;/code&gt;object from required fields to optional fields.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Description of the user datainterface User { id: number; firstName: string; lastName: string; email: string; bio: string;};// This is the user data fetchedconst userData: User = { id: 12345, firstName: "Jamin", lastName: "Doe", email: "hellojamin@test.com", bio: "Legendary Gamer and everything in between",};//Function to update the user infoconst updateUserInfo = (userId: number, updatedInfo: Partial&amp;lt;User&amp;gt;) =&amp;gt; { // Logic to update the user's info with the provided data // Using the partial type, all fields becomes optional updatedInfo.lastName; //(property) lastName?: string | undefined updatedInfo.email; //(property) email?: string | undefined};// Example usageconst userId = 12345;const updatedInfo: Partial&amp;lt;User&amp;gt; = { firstName: "John", bio: "Web Developer",};updateUserInfo(userId, updatedInfo);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the &lt;code&gt;Partial&lt;/code&gt; utility type converts all the &lt;code&gt;User&lt;/code&gt; object properties to optional fields.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2.&lt;/strong&gt; &lt;code&gt;Required&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Required&lt;/code&gt; utility type is the opposite of the &lt;code&gt;Partial&lt;/code&gt; utility type. It transforms all the fields of your &lt;code&gt;Type&lt;/code&gt; into required fields. Imagine you have a data type of &lt;code&gt;UserRegistration&lt;/code&gt; with some optional fields, but youd like to make all the fields required when using the data. You can achieve this using the &lt;code&gt;Required&lt;/code&gt; utility type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface UserRegistration { username?: string; password?: string; email: string; fullName?: string;}const registerUser = (userData: Required&amp;lt;UserRegistration&amp;gt;) =&amp;gt; { // Logic to register the user with the provided data};// Example usageconst userData: Required&amp;lt;UserRegistration&amp;gt; = { email: "user@example.com",};// throws an error// Type '{ email: string; }' is missing the following properties from type 'Required&amp;lt;UserRegistration&amp;gt;': username, password, fullNameregisterUser(userData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3.&lt;/strong&gt; &lt;code&gt;Pick&amp;lt;Type, Keys&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This utility type enables you to selectively pick properties from a &lt;code&gt;Type&lt;/code&gt; using the &lt;code&gt;Keys&lt;/code&gt; properties of the object you want to pick from.&lt;/p&gt;

&lt;p&gt;Lets say you have a product catalog in your application and would like to list available products for a catalog without showing all the data properties of the products. You can create a simplified version of the original product object for listing available products.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Let's create a simplified version of the product for the product listingtype SimplifiedProduct = Pick&amp;lt;Product, "id" | "name" | "price" | "category"&amp;gt;;const product: Product = { id: "1001", name: "Laptop", description: "High-performance laptop", price: 1200, category: "Electronics", stock: 10 // ...};const simplifiedProduct: SimplifiedProduct = { id: product.id, name: product.name, price: product.price, category: product.category};console.log(simplifiedProduct);// Output: { id: "1001, name: "Laptop", price: 1200, category: "Electronics" }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Pick&lt;/code&gt; utility type can be very useful when you have a very complex data object and only want to display a fraction of that data object to your users.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4.&lt;/strong&gt; &lt;code&gt;Omit&amp;lt;Type, Keys&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Omit&amp;lt;Type, Keys&amp;gt;&lt;/code&gt; type removes specified &lt;code&gt;Keys&lt;/code&gt; properties from the &lt;code&gt;Type&lt;/code&gt; and provides you with a &lt;code&gt;Type&lt;/code&gt; without those properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Let's create a simplified version of the product by excluding certain propertiestype SimplifiedProduct = Omit&amp;lt;Product, "description" | "stock"&amp;gt;;const product: Product = { id: "1001", name: "Laptop", description: "High-performance laptop", price: 1200, category: "Electronics", stock: 10 // ...};//description and stock are excluded from the product propertiesconst simplifiedProduct: SimplifiedProduct = { id: product.id, name: product.name, price: product.price, category: product.category};console.log(simplifiedProduct);// Output: { id: "1001, name: "Laptop", price: 1200, category: "Electronics" }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;5.&lt;/strong&gt; &lt;code&gt;ReturnType&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The return type is used to get a functions return type. This enables you to extract and use the type that a function will return when invoked. It works by taking in a function as its parameter and returning the &lt;code&gt;Type&lt;/code&gt; of the returned value of the function.&lt;/p&gt;

&lt;p&gt;Consider the &lt;code&gt;fetchDataFromApi&lt;/code&gt; example below and how the return type of the function was derived using the &lt;code&gt;ReturnType&lt;/code&gt; utility type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type ApiResponse = { success: boolean; data: any; // Assuming data can be of any type};type ApiFetchFunction = () =&amp;gt; Promise&amp;lt;ApiResponse&amp;gt;;function fetchDataFromApi(endpoint: string): ApiFetchFunction { // Simulating fetching data from the API const fetchFunction: ApiFetchFunction = async () =&amp;gt; { const response = await fetch(endpoint); const data = await response.json(); return { success: true, data }; }; return fetchFunction;}// Usageconst fetchProductData = fetchDataFromApi('https://api.example.com/products');// Get the return type from the functiontype ProductDataResponse = ReturnType&amp;lt;typeof fetchProductData&amp;gt;;// Use the function's return typeasync function handleProductData() { const response: ProductDataResponse = await fetchProductData(); console.log('Product data:', response.data);}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;6.&lt;/strong&gt; &lt;code&gt;Awaited&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Awaited&lt;/code&gt; type is used for asynchronous functions and operations to determine the data type that the function or operation would resolve. Consider the product example you used previously. Imagine you need to fetch the product data from an API. The API service returns a &lt;code&gt;Promise&lt;/code&gt; with the product data. You want to handle this asynchronously and extract the type of the resolved data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// A function that simulates fetching product data from an APIconst fetchProductFromAPI = (): Promise&amp;lt;Product&amp;gt; =&amp;gt; { return new Promise(resolve =&amp;gt; { // Simulate an asynchronous API call setTimeout(() =&amp;gt; { resolve({ id: "1001", name: "Laptop", description: "High-performance laptop", price: 1200, category: "Electronics", stock: 10 }); }, 1000); });};// Use ReturnType to get the return type of the async function and use// Awaited to retrieve the type of the async callconst getProductData = async (): Promise&amp;lt;Awaited&amp;lt;ReturnType&amp;lt;typeof fetchProductFromAPI&amp;gt;&amp;gt;&amp;gt; =&amp;gt; { const productData = await fetchProductFromAPI(); return productData;};getProductData().then(data =&amp;gt; { console.log("Product data:", data); /* Output: Product data: { id: '1001', name: 'Laptop', description: 'High-performance laptop', price: 1200, category: 'Electronics', stock: 10 } */});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's interesting to note that the &lt;code&gt;Awaited&lt;/code&gt; utility transforms types in a recursive manner. So, no matter how deeply nested a &lt;code&gt;Promise&lt;/code&gt; is, it will always resolve its value. For example, the code below would transform the nested async request to a single data type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Data = Awaited&amp;lt;Promise&amp;lt;Promise&amp;lt;string&amp;gt;&amp;gt;&amp;gt;;//type Data = string
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;7.&lt;/strong&gt; &lt;code&gt;Record&amp;lt;Keys, Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Record&lt;/code&gt; utility type enables you to construct an object type with &lt;code&gt;Keys&lt;/code&gt; as its property keys and &lt;code&gt;Type&lt;/code&gt; as its property values. The &lt;code&gt;Keys&lt;/code&gt; passed to the &lt;code&gt;Record&lt;/code&gt; ensure that only those specific keys can be assigned values of &lt;code&gt;Type&lt;/code&gt;. This is particularly useful when you want to narrow down your records by only accepting specific keys.&lt;/p&gt;

&lt;p&gt;Lets use a real-world scenario to understand this better:&lt;/p&gt;

&lt;p&gt;You're creating a notification system for an application that notifies your users based on specific actions they take or responses to a request they make.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;Record&lt;/code&gt; utility like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type NotificationTypes = 'error' | 'success' | 'warning';type IconTypes = 'errorIcon' | 'successIcon' | 'warningIcon';type IconColors = 'red' | 'green' | 'yellow';const notificationIcons: Record&amp;lt; NotificationTypes, { iconType: IconTypes; iconColor: IconColors }&amp;gt; = { error: { iconType: 'errorIcon', iconColor: 'red' }, success: { iconType: 'successIcon', iconColor: 'green' }, warning: { iconType: 'warningIcon', iconColor: 'yellow' }};console.log(notificationIcons.error)// OUTPUT: { iconType: 'errorIcon', iconColor: 'red' }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, you specified the &lt;code&gt;Keys&lt;/code&gt; for the object to be a &lt;code&gt;Union&lt;/code&gt; type of either &lt;code&gt;error&lt;/code&gt;, &lt;code&gt;success&lt;/code&gt;, or &lt;code&gt;warning&lt;/code&gt; and assigned them to a property value of &lt;code&gt;{ iconType: IconTypes; iconColor: IconColors }&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With this, youve created a constraint of records where the &lt;code&gt;notificationIcons&lt;/code&gt; can only be accessed by one of the &lt;code&gt;NotificationTypes&lt;/code&gt;. Trying to access the &lt;code&gt;notificationIcons&lt;/code&gt; without a known &lt;code&gt;NotificationTypes&lt;/code&gt; will throw an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(notificationIcons.completed)// Property 'completed' does not exist on type 'Record&amp;lt;NotificationTypes, { iconType: IconTypes; iconColor: IconColors; }&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;8.&lt;/strong&gt; &lt;code&gt;Readonly&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Readonly&lt;/code&gt; type transforms the object properties of a &lt;code&gt;Type&lt;/code&gt; to 'read-only' so its values cannot be reassigned after initialization.&lt;/p&gt;

&lt;p&gt;Example: Suppose you have a configuration object for a web application with various settings, and you want to ensure that once the configuration is set, it cannot be modified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface AppConfig { apiUrl: string; maxRequestsPerMinute: number; analyticsEnabled: boolean;}const initialConfig: Readonly&amp;lt;AppConfig&amp;gt; = { apiUrl: '&amp;lt;https://api.example.com&amp;gt;', maxRequestsPerMinute: 1000, analyticsEnabled: true,};// Attempt to modify a property (will result in a TypeScript error)initialConfig.apiUrl = '&amp;lt;https://new-api.example.com&amp;gt;';// Error: Cannot assign to 'apiUrl' because it is a read-only property.function displayConfig(config: Readonly&amp;lt;AppConfig&amp;gt;) { console.log('API URL:', config.apiUrl); console.log('Max Requests Per Minute:', config.maxRequestsPerMinute); console.log('Analytics Enabled:', config.analyticsEnabled);}displayConfig(initialConfig);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;9.&lt;/strong&gt; &lt;code&gt;NonNullable&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;NonNullable&lt;/code&gt; type transforms a type by removing all &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt; from the input &lt;code&gt;Type&lt;/code&gt; passed to it.&lt;/p&gt;

&lt;p&gt;Example: Let's say you have a union type that accepts a &lt;code&gt;string&lt;/code&gt;, or a &lt;code&gt;number&lt;/code&gt;, as values. The type can sometimes be (&lt;code&gt;undefined&lt;/code&gt; or &lt;code&gt;null&lt;/code&gt;) as optional values. In the case where you dont want to accept &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt; when reusing this type, you can stripe off the &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt; fields using &lt;code&gt;NonNullable&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type UserID = string | number | null | undefined//Works fine as expectedconst userByIDString = "100"// error: Type 'undefined' is not assignable to type 'NonNullable&amp;lt;UserID&amp;gt;'const userByID: NonNullable&amp;lt;UserID&amp;gt; = undefined//Works fine as expectedconst userByIDNumber: NonNullable&amp;lt;UserID&amp;gt; = 102
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a list of all the available built-in utility types, check out the official TypeScript &lt;a href="https://www.typescriptlang.org/docs/handbook/utility-types.html" rel="noopener noreferrer"&gt;documentation.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Custom types in TypeScript&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Aside from using the built-in utility type from TypeScript, the language also offers the flexibility to create custom utility types to suit your needs where needed. Lets create a custom type in TypeScript that you can use to transform other types. For this example, youll create a utility type that accepts &lt;code&gt;Type&lt;/code&gt; as an object type and filters the keys of the object by the &lt;code&gt;Key&lt;/code&gt;passed to the utility type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Custom utility type declaration type FilterKeysByType&amp;lt;Type, KeyType&amp;gt; = { [key in keyof Type as Type[key] extends KeyType ? key: never]: Type[key];}// Usage exampleinterface Person { name: string; age: number; email: string; isAdmin: boolean;}type StringKeys = FilterKeysByType&amp;lt;Person, string&amp;gt;;//OUTPUT: { name: string, email: string }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets break down the custom utility line by line to understand it better,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;type FilterKeysByType&amp;lt;Type, KeyType&amp;gt;&lt;/code&gt; is the type definition, and it accepts two things: the &lt;code&gt;Type&lt;/code&gt; you want to transform and the &lt;code&gt;KeyType&lt;/code&gt; to filter by.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the second line, three major things are happening:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Custom types vs. utility types&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Should you create custom types over TypeScript's built-in utility types?&lt;/p&gt;

&lt;p&gt;That depends on the level of transformation and abstraction you're performing. If you want to perform complex transformations that go beyond what TypeScript's built-in features offer, you should consider creating your own custom types.&lt;/p&gt;

&lt;p&gt;Utility types are built-in features of TypeScript, and they don't require any external libraries or more lines of code for you to define and use them. Since they're built-in features of TypeScript, they're well-known and familiar to most developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Combining custom types with utility types&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Utilizing TypeScripts capabilities to create custom types lets you combine a custom type with a utility type to create a customized utility type that is tailored to fit the needs of your project.&lt;/p&gt;

&lt;p&gt;Lets explore this with an example. Say you want to create a custom type that transforms another type to make specific properties of that type optional. You can create such a custom type by utilizing TypeScripts already existing utility types to achieve this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type PartialBy&amp;lt;Type, Key extends keyof Type&amp;gt; = Omit&amp;lt;Type, Key&amp;gt; &amp;amp; Partial&amp;lt;Pick&amp;lt;Type, Key&amp;gt;&amp;gt;;// Usageinterface User {id: string;name: string;email: string;}const partialUser: PartialBy&amp;lt;User, 'email'&amp;gt; = {id: '123',name: 'John Doe',};// email is optional in partialUserconsole.log(partialUser);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;PartialBy&lt;/code&gt; is a utility type that takes two parameters: &lt;code&gt;Type&lt;/code&gt;, which is the original type, and &lt;code&gt;Key&lt;/code&gt;, which represents the keys that you want to make partial. It uses &lt;code&gt;Omit&lt;/code&gt; to remove the specified keys from the original type and &lt;code&gt;Partial&amp;lt;Pick&amp;gt;&lt;/code&gt; to make those keys optional.&lt;/p&gt;

&lt;p&gt;With this, the &lt;code&gt;PartialBy&lt;/code&gt; custom utility can transform the &lt;code&gt;Key&lt;/code&gt; of any &lt;code&gt;Type&lt;/code&gt; passed to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Summing up: why you should use utility types&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Utility types in TypeScript can help you write sturdy, maintainable types. You can use them to make your type declarations more flexible, expressive, and reusable. They also give you the ability to combine them with custom types to create more powerful type declarations.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>programming</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
