From 5451b0707e2bd6a66bd0f8ae8e1d0385b81dc363 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 21:16:10 +0530
Subject: [PATCH 01/12] Created using Colaboratory My first round of working
---
Mudasarinfracloud.ipynb | 568 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 568 insertions(+)
create mode 100644 Mudasarinfracloud.ipynb
diff --git a/Mudasarinfracloud.ipynb b/Mudasarinfracloud.ipynb
new file mode 100644
index 0000000000..dcf5bcfefe
--- /dev/null
+++ b/Mudasarinfracloud.ipynb
@@ -0,0 +1,568 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "authorship_tag": "ABX9TyNvBXHoZW71MHcuumzXAp+z",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "65lHeRTBMCBt",
+ "outputId": "920c903f-2c58-4784-b253-d8f15ec5310c"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
+ "Collecting pyshorteners\n",
+ " Downloading pyshorteners-1.0.1.tar.gz (10.0 kB)\n",
+ " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
+ "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from pyshorteners) (2.27.1)\n",
+ "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (1.26.15)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (2022.12.7)\n",
+ "Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (2.0.12)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (3.4)\n",
+ "Building wheels for collected packages: pyshorteners\n",
+ " Building wheel for pyshorteners (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
+ " Created wheel for pyshorteners: filename=pyshorteners-1.0.1-py3-none-any.whl size=17479 sha256=afe94b3bc7dc3f7e592db1b9208bf58a98b1e709af4ec395a2459e01b7ac994e\n",
+ " Stored in directory: /root/.cache/pip/wheels/d5/ff/b3/16d8906f92ab0b042f76a4696fcea11d291d79a2b3a3de1e78\n",
+ "Successfully built pyshorteners\n",
+ "Installing collected packages: pyshorteners\n",
+ "Successfully installed pyshorteners-1.0.1\n"
+ ]
+ }
+ ],
+ "source": [
+ "pip install pyshorteners"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=E6GPMTDx41Y\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e3Pg6XaLMfAg",
+ "outputId": "a185e7c9-524a-4285-a59b-efae85ce732e"
+ },
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2g47dx37\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=U8_YEWuBybI\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "-_cshk2dNq-r",
+ "outputId": "3f3f429f-27a6-44b2-fcfb-a2a7ffa2ab75"
+ },
+ "execution_count": 5,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2h4vcxuk\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=ZSiXZxVpVhs\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "dHNc7GWMOi2S",
+ "outputId": "81e8f8f2-1445-43e7-d510-245c2131a0fd"
+ },
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2r2pcw4c\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=vYCjjAz3UD0\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "gbEFz6OCOvZO",
+ "outputId": "180287e0-fc17-4e7d-90c3-60b9bf4a9385"
+ },
+ "execution_count": 7,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2fzbn924\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://stackoverflow.blog/2021/12/30/how-often-do-people-actually-copy-and-paste-from-stack-overflow-now-we-know/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "YfHDQiwHO8Ob",
+ "outputId": "23074cb2-6e2d-4b89-bbef-a2e5a0d06dd9"
+ },
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2knnnyae\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://en.wikipedia.org/wiki/Artificial_Intelligence_Markup_Language\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "I9Z3VsP6PFFw",
+ "outputId": "cc574317-ed7c-4b6b-a402-722b2bba801f"
+ },
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2occ6bkt\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "OKIstCCnPNqz",
+ "outputId": "e9348b71-6ec0-45b4-efd8-e4e7deb6e78e"
+ },
+ "execution_count": 10,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/cdgsybc\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/?ranMID=39197&ranEAID=yNfEamYSgXk&ranSiteID=yNfEamYSgXk-FaJv9m4qNyvV_Sf4.6AWTw&LSNPUBID=yNfEamYSgXk&utm_source=aff-campaign&utm_medium=udemyads\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "2A7ZhezBPWfI",
+ "outputId": "985aeed1-47e3-42a0-d8c1-2fb4e2f1d35b"
+ },
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2pgefbna\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/the-complete-web-development-bootcamp/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "3t0NPFBaPcxX",
+ "outputId": "36af6c88-062d-4304-a3dc-a29e05049d51"
+ },
+ "execution_count": 12,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/y9fhfkju\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/100-days-of-code/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "sZMul52QP1yP",
+ "outputId": "304362de-3df7-4f21-912d-00cc4d2d5e10"
+ },
+ "execution_count": 13,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/y23h4x9l\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/aws-certified-cloud-practitioner-new/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "IWSamMgKP9bt",
+ "outputId": "cfe11c31-a844-4868-e563-5bae26f17497"
+ },
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/yd8k7zmw\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "hSR0CGjUQEGu",
+ "outputId": "c64b3109-143b-46c2-f3b5-d54723b02faa"
+ },
+ "execution_count": 15,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2o7km274\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/react-the-complete-guide-incl-redux/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "lGEkCwUBQL54",
+ "outputId": "320dd29d-9004-4452-ef2f-927707255055"
+ },
+ "execution_count": 16,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/u5yxn5u\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from collections import defaultdict\n",
+ "\n",
+ "class ShortenerMetricsAPI:\n",
+ " def __init__(self):\n",
+ " self.shortened_links = defaultdict(int)\n",
+ " \n",
+ " def add_shortened_link(self, url):\n",
+ " domain = self.get_domain(url)\n",
+ " self.shortened_links[domain] += 1\n",
+ " \n",
+ " def get_domain(self, url):\n",
+ " # extract the domain from the URL\n",
+ " return url.split(\"//\")[-1].split(\"/\")[0].split(\"?\")[0].split(\"#\")[0]\n",
+ " \n",
+ " def get_top_domains(self, n=3):\n",
+ " # sort the domains by the number of times they have been shortened\n",
+ " sorted_domains = sorted(self.shortened_links.items(), key=lambda x: x[1], reverse=True)\n",
+ " # return the top n domains\n",
+ " return sorted_domains[:n]\n"
+ ],
+ "metadata": {
+ "id": "9FDajndyNPpH"
+ },
+ "execution_count": 4,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "metrics_api = ShortenerMetricsAPI()\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=E6GPMTDx41Y\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=U8_YEWuBybI\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=ZSiXZxVpVhs\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=vYCjjAz3UD0\")\n",
+ "metrics_api.add_shortened_link(\"https://stackoverflow.blog/2021/12/30/how-often-do-people-actually-copy-and-paste-from-stack-overflow-now-we-know/\")\n",
+ "metrics_api.add_shortened_link(\"https://en.wikipedia.org/wiki/Artificial_Intelligence_Markup_Language\")\n",
+ "metrics_api.add_shortened_link(\"https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/?ranMID=39197&ranEAID=yNfEamYSgXk&ranSiteID=yNfEamYSgXk-FaJv9m4qNyvV_Sf4.6AWTw&LSNPUBID=yNfEamYSgXk&utm_source=aff-campaign&utm_medium=udemyads\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/the-complete-web-development-bootcamp/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/100-days-of-code/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/aws-certified-cloud-practitioner-new/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/react-the-complete-guide-incl-redux/\")\n",
+ "\n",
+ "top_domains = metrics_api.get_top_domains()\n",
+ "for domain, count in top_domains:\n",
+ " print(f\"{domain}: {count}\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "MOO0koj2bUzR",
+ "outputId": "24632f0a-8872-46ba-f01e-9e9889f2b57a"
+ },
+ "execution_count": 24,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "www.udemy.com: 6\n",
+ "www.youtube.com: 4\n",
+ "en.wikipedia.org: 2\n"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From 7491dddd719af02f1e8c44366f29231d9759d12e Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 22:01:26 +0530
Subject: [PATCH 02/12] Created using Colaboratory my first round of working
with the assignment
From adc2084e1a44837498931b139d891bf57e42a92d Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 22:12:51 +0530
Subject: [PATCH 03/12] Created using Colaboratory 1st round of work
From 67bc5f98ef97b6371826f34e596a0e3506dda085 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 22:17:36 +0530
Subject: [PATCH 04/12] Created using Colaboratory url shortner by Mudasar
From 4be88be1161a8428ccad8c3cbf493dd7ef1875fc Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 22:27:28 +0530
Subject: [PATCH 05/12] Created using Colaboratory
From 9798106f2d93e94bb65e95f7d2207b673b083374 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 22:32:42 +0530
Subject: [PATCH 06/12] Created using Colaboratory
From 42a4bf427599e33d6fc57335a143df948420e1f4 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Thu, 11 May 2023 23:26:26 +0530
Subject: [PATCH 07/12] Created using Colaboratory
---
Mudasarinfracloud.ipynb | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/Mudasarinfracloud.ipynb b/Mudasarinfracloud.ipynb
index dcf5bcfefe..5e7e0ca4fc 100644
--- a/Mudasarinfracloud.ipynb
+++ b/Mudasarinfracloud.ipynb
@@ -28,7 +28,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@@ -86,7 +86,7 @@
"id": "e3Pg6XaLMfAg",
"outputId": "a185e7c9-524a-4285-a59b-efae85ce732e"
},
- "execution_count": 3,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -119,7 +119,7 @@
"id": "-_cshk2dNq-r",
"outputId": "3f3f429f-27a6-44b2-fcfb-a2a7ffa2ab75"
},
- "execution_count": 5,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -152,7 +152,7 @@
"id": "dHNc7GWMOi2S",
"outputId": "81e8f8f2-1445-43e7-d510-245c2131a0fd"
},
- "execution_count": 6,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -185,7 +185,7 @@
"id": "gbEFz6OCOvZO",
"outputId": "180287e0-fc17-4e7d-90c3-60b9bf4a9385"
},
- "execution_count": 7,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -218,7 +218,7 @@
"id": "YfHDQiwHO8Ob",
"outputId": "23074cb2-6e2d-4b89-bbef-a2e5a0d06dd9"
},
- "execution_count": 8,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -251,7 +251,7 @@
"id": "I9Z3VsP6PFFw",
"outputId": "cc574317-ed7c-4b6b-a402-722b2bba801f"
},
- "execution_count": 9,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -284,7 +284,7 @@
"id": "OKIstCCnPNqz",
"outputId": "e9348b71-6ec0-45b4-efd8-e4e7deb6e78e"
},
- "execution_count": 10,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -317,7 +317,7 @@
"id": "2A7ZhezBPWfI",
"outputId": "985aeed1-47e3-42a0-d8c1-2fb4e2f1d35b"
},
- "execution_count": 11,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -350,7 +350,7 @@
"id": "3t0NPFBaPcxX",
"outputId": "36af6c88-062d-4304-a3dc-a29e05049d51"
},
- "execution_count": 12,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -383,7 +383,7 @@
"id": "sZMul52QP1yP",
"outputId": "304362de-3df7-4f21-912d-00cc4d2d5e10"
},
- "execution_count": 13,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -416,7 +416,7 @@
"id": "IWSamMgKP9bt",
"outputId": "cfe11c31-a844-4868-e563-5bae26f17497"
},
- "execution_count": 14,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -449,7 +449,7 @@
"id": "hSR0CGjUQEGu",
"outputId": "c64b3109-143b-46c2-f3b5-d54723b02faa"
},
- "execution_count": 15,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -482,7 +482,7 @@
"id": "lGEkCwUBQL54",
"outputId": "320dd29d-9004-4452-ef2f-927707255055"
},
- "execution_count": 16,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -519,7 +519,7 @@
"metadata": {
"id": "9FDajndyNPpH"
},
- "execution_count": 4,
+ "execution_count": null,
"outputs": []
},
{
@@ -551,7 +551,7 @@
"id": "MOO0koj2bUzR",
"outputId": "24632f0a-8872-46ba-f01e-9e9889f2b57a"
},
- "execution_count": 24,
+ "execution_count": null,
"outputs": [
{
"output_type": "stream",
From 128157876e880e23a46615ef864e3acc1cea2ec3 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Fri, 12 May 2023 05:50:08 +0530
Subject: [PATCH 08/12] Created using Colaboratory
---
Copy_of_Mudasarinfrac.ipynb | 568 ++++++++++++++++++++++++++++++++++++
1 file changed, 568 insertions(+)
create mode 100644 Copy_of_Mudasarinfrac.ipynb
diff --git a/Copy_of_Mudasarinfrac.ipynb b/Copy_of_Mudasarinfrac.ipynb
new file mode 100644
index 0000000000..9db933e882
--- /dev/null
+++ b/Copy_of_Mudasarinfrac.ipynb
@@ -0,0 +1,568 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "authorship_tag": "ABX9TyNvBXHoZW71MHcuumzXAp+z",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "65lHeRTBMCBt",
+ "outputId": "920c903f-2c58-4784-b253-d8f15ec5310c"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
+ "Collecting pyshorteners\n",
+ " Downloading pyshorteners-1.0.1.tar.gz (10.0 kB)\n",
+ " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
+ "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from pyshorteners) (2.27.1)\n",
+ "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (1.26.15)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (2022.12.7)\n",
+ "Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (2.0.12)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (3.4)\n",
+ "Building wheels for collected packages: pyshorteners\n",
+ " Building wheel for pyshorteners (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
+ " Created wheel for pyshorteners: filename=pyshorteners-1.0.1-py3-none-any.whl size=17479 sha256=afe94b3bc7dc3f7e592db1b9208bf58a98b1e709af4ec395a2459e01b7ac994e\n",
+ " Stored in directory: /root/.cache/pip/wheels/d5/ff/b3/16d8906f92ab0b042f76a4696fcea11d291d79a2b3a3de1e78\n",
+ "Successfully built pyshorteners\n",
+ "Installing collected packages: pyshorteners\n",
+ "Successfully installed pyshorteners-1.0.1\n"
+ ]
+ }
+ ],
+ "source": [
+ "pip install pyshorteners"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=E6GPMTDx41Y\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e3Pg6XaLMfAg",
+ "outputId": "a185e7c9-524a-4285-a59b-efae85ce732e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2g47dx37\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=U8_YEWuBybI\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "-_cshk2dNq-r",
+ "outputId": "3f3f429f-27a6-44b2-fcfb-a2a7ffa2ab75"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2h4vcxuk\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=ZSiXZxVpVhs\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "dHNc7GWMOi2S",
+ "outputId": "81e8f8f2-1445-43e7-d510-245c2131a0fd"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2r2pcw4c\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=vYCjjAz3UD0\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "gbEFz6OCOvZO",
+ "outputId": "180287e0-fc17-4e7d-90c3-60b9bf4a9385"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2fzbn924\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://stackoverflow.blog/2021/12/30/how-often-do-people-actually-copy-and-paste-from-stack-overflow-now-we-know/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "YfHDQiwHO8Ob",
+ "outputId": "23074cb2-6e2d-4b89-bbef-a2e5a0d06dd9"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2knnnyae\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://en.wikipedia.org/wiki/Artificial_Intelligence_Markup_Language\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "I9Z3VsP6PFFw",
+ "outputId": "cc574317-ed7c-4b6b-a402-722b2bba801f"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2occ6bkt\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "OKIstCCnPNqz",
+ "outputId": "e9348b71-6ec0-45b4-efd8-e4e7deb6e78e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/cdgsybc\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/?ranMID=39197&ranEAID=yNfEamYSgXk&ranSiteID=yNfEamYSgXk-FaJv9m4qNyvV_Sf4.6AWTw&LSNPUBID=yNfEamYSgXk&utm_source=aff-campaign&utm_medium=udemyads\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "2A7ZhezBPWfI",
+ "outputId": "985aeed1-47e3-42a0-d8c1-2fb4e2f1d35b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2pgefbna\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/the-complete-web-development-bootcamp/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "3t0NPFBaPcxX",
+ "outputId": "36af6c88-062d-4304-a3dc-a29e05049d51"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/y9fhfkju\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/100-days-of-code/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "sZMul52QP1yP",
+ "outputId": "304362de-3df7-4f21-912d-00cc4d2d5e10"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/y23h4x9l\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/aws-certified-cloud-practitioner-new/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "IWSamMgKP9bt",
+ "outputId": "cfe11c31-a844-4868-e563-5bae26f17497"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/yd8k7zmw\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "hSR0CGjUQEGu",
+ "outputId": "c64b3109-143b-46c2-f3b5-d54723b02faa"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2o7km274\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/react-the-complete-guide-incl-redux/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "lGEkCwUBQL54",
+ "outputId": "320dd29d-9004-4452-ef2f-927707255055"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/u5yxn5u\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from collections import defaultdict\n",
+ "\n",
+ "class ShortenerMetricsAPI:\n",
+ " def __init__(self):\n",
+ " self.shortened_links = defaultdict(int)\n",
+ " \n",
+ " def add_shortened_link(self, url):\n",
+ " domain = self.get_domain(url)\n",
+ " self.shortened_links[domain] += 1\n",
+ " \n",
+ " def get_domain(self, url):\n",
+ " # extract the domain from the URL\n",
+ " return url.split(\"//\")[-1].split(\"/\")[0].split(\"?\")[0].split(\"#\")[0]\n",
+ " \n",
+ " def get_top_domains(self, n=3):\n",
+ " # sort the domains by the number of times they have been shortened\n",
+ " sorted_domains = sorted(self.shortened_links.items(), key=lambda x: x[1], reverse=True)\n",
+ " # return the top n domains\n",
+ " return sorted_domains[:n]\n"
+ ],
+ "metadata": {
+ "id": "9FDajndyNPpH"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "metrics_api = ShortenerMetricsAPI()\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=E6GPMTDx41Y\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=U8_YEWuBybI\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=ZSiXZxVpVhs\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=vYCjjAz3UD0\")\n",
+ "metrics_api.add_shortened_link(\"https://stackoverflow.blog/2021/12/30/how-often-do-people-actually-copy-and-paste-from-stack-overflow-now-we-know/\")\n",
+ "metrics_api.add_shortened_link(\"https://en.wikipedia.org/wiki/Artificial_Intelligence_Markup_Language\")\n",
+ "metrics_api.add_shortened_link(\"https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/?ranMID=39197&ranEAID=yNfEamYSgXk&ranSiteID=yNfEamYSgXk-FaJv9m4qNyvV_Sf4.6AWTw&LSNPUBID=yNfEamYSgXk&utm_source=aff-campaign&utm_medium=udemyads\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/the-complete-web-development-bootcamp/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/100-days-of-code/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/aws-certified-cloud-practitioner-new/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/react-the-complete-guide-incl-redux/\")\n",
+ "\n",
+ "top_domains = metrics_api.get_top_domains()\n",
+ "for domain, count in top_domains:\n",
+ " print(f\"{domain}: {count}\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "MOO0koj2bUzR",
+ "outputId": "24632f0a-8872-46ba-f01e-9e9889f2b57a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "www.udemy.com: 6\n",
+ "www.youtube.com: 4\n",
+ "en.wikipedia.org: 2\n"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From f2e24d838c6b4d340014c89b281edab844a19ce6 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Fri, 12 May 2023 05:51:21 +0530
Subject: [PATCH 09/12] Created using Colaboratory
From c1a15b89faf75e56a39fa92f9056478a257d4ac4 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Fri, 12 May 2023 05:57:43 +0530
Subject: [PATCH 10/12] Created using Colaboratory
From 0dd175876048d15a800c4deb53d03c61224b5229 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Fri, 12 May 2023 06:07:27 +0530
Subject: [PATCH 11/12] Created using Colaboratory
---
Mudasarinfracloudupdated.ipynb | 568 +++++++++++++++++++++++++++++++++
1 file changed, 568 insertions(+)
create mode 100644 Mudasarinfracloudupdated.ipynb
diff --git a/Mudasarinfracloudupdated.ipynb b/Mudasarinfracloudupdated.ipynb
new file mode 100644
index 0000000000..4d5792f0be
--- /dev/null
+++ b/Mudasarinfracloudupdated.ipynb
@@ -0,0 +1,568 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "authorship_tag": "ABX9TyNvBXHoZW71MHcuumzXAp+z",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "65lHeRTBMCBt",
+ "outputId": "920c903f-2c58-4784-b253-d8f15ec5310c"
+ },
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
+ "Collecting pyshorteners\n",
+ " Downloading pyshorteners-1.0.1.tar.gz (10.0 kB)\n",
+ " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
+ "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from pyshorteners) (2.27.1)\n",
+ "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (1.26.15)\n",
+ "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (2022.12.7)\n",
+ "Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (2.0.12)\n",
+ "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->pyshorteners) (3.4)\n",
+ "Building wheels for collected packages: pyshorteners\n",
+ " Building wheel for pyshorteners (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
+ " Created wheel for pyshorteners: filename=pyshorteners-1.0.1-py3-none-any.whl size=17479 sha256=afe94b3bc7dc3f7e592db1b9208bf58a98b1e709af4ec395a2459e01b7ac994e\n",
+ " Stored in directory: /root/.cache/pip/wheels/d5/ff/b3/16d8906f92ab0b042f76a4696fcea11d291d79a2b3a3de1e78\n",
+ "Successfully built pyshorteners\n",
+ "Installing collected packages: pyshorteners\n",
+ "Successfully installed pyshorteners-1.0.1\n"
+ ]
+ }
+ ],
+ "source": [
+ "pip install pyshorteners"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=E6GPMTDx41Y\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "e3Pg6XaLMfAg",
+ "outputId": "a185e7c9-524a-4285-a59b-efae85ce732e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2g47dx37\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=U8_YEWuBybI\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "-_cshk2dNq-r",
+ "outputId": "3f3f429f-27a6-44b2-fcfb-a2a7ffa2ab75"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2h4vcxuk\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=ZSiXZxVpVhs\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "dHNc7GWMOi2S",
+ "outputId": "81e8f8f2-1445-43e7-d510-245c2131a0fd"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2r2pcw4c\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.youtube.com/watch?v=vYCjjAz3UD0\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "gbEFz6OCOvZO",
+ "outputId": "180287e0-fc17-4e7d-90c3-60b9bf4a9385"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2fzbn924\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://stackoverflow.blog/2021/12/30/how-often-do-people-actually-copy-and-paste-from-stack-overflow-now-we-know/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "YfHDQiwHO8Ob",
+ "outputId": "23074cb2-6e2d-4b89-bbef-a2e5a0d06dd9"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2knnnyae\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://en.wikipedia.org/wiki/Artificial_Intelligence_Markup_Language\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "I9Z3VsP6PFFw",
+ "outputId": "cc574317-ed7c-4b6b-a402-722b2bba801f"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2occ6bkt\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "OKIstCCnPNqz",
+ "outputId": "e9348b71-6ec0-45b4-efd8-e4e7deb6e78e"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/cdgsybc\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/?ranMID=39197&ranEAID=yNfEamYSgXk&ranSiteID=yNfEamYSgXk-FaJv9m4qNyvV_Sf4.6AWTw&LSNPUBID=yNfEamYSgXk&utm_source=aff-campaign&utm_medium=udemyads\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "2A7ZhezBPWfI",
+ "outputId": "985aeed1-47e3-42a0-d8c1-2fb4e2f1d35b"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2pgefbna\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/the-complete-web-development-bootcamp/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "3t0NPFBaPcxX",
+ "outputId": "36af6c88-062d-4304-a3dc-a29e05049d51"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/y9fhfkju\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/100-days-of-code/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "sZMul52QP1yP",
+ "outputId": "304362de-3df7-4f21-912d-00cc4d2d5e10"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/y23h4x9l\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/aws-certified-cloud-practitioner-new/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "IWSamMgKP9bt",
+ "outputId": "cfe11c31-a844-4868-e563-5bae26f17497"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/yd8k7zmw\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "hSR0CGjUQEGu",
+ "outputId": "c64b3109-143b-46c2-f3b5-d54723b02faa"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/2o7km274\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "import pyshorteners\n",
+ "\n",
+ "def shorten_url(url):\n",
+ " s = pyshorteners.Shortener()\n",
+ " shortened_url = s.tinyurl.short(url)\n",
+ " return shortened_url\n",
+ "\n",
+ "# Example usage\n",
+ "long_url = \"https://www.udemy.com/course/react-the-complete-guide-incl-redux/\"\n",
+ "short_url = shorten_url(long_url)\n",
+ "print(\"Short URL:\", short_url)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "lGEkCwUBQL54",
+ "outputId": "320dd29d-9004-4452-ef2f-927707255055"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Short URL: https://tinyurl.com/u5yxn5u\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from collections import defaultdict\n",
+ "\n",
+ "class ShortenerMetricsAPI:\n",
+ " def __init__(self):\n",
+ " self.shortened_links = defaultdict(int)\n",
+ " \n",
+ " def add_shortened_link(self, url):\n",
+ " domain = self.get_domain(url)\n",
+ " self.shortened_links[domain] += 1\n",
+ " \n",
+ " def get_domain(self, url):\n",
+ " # extract the domain from the URL\n",
+ " return url.split(\"//\")[-1].split(\"/\")[0].split(\"?\")[0].split(\"#\")[0]\n",
+ " \n",
+ " def get_top_domains(self, n=3):\n",
+ " # sort the domains by the number of times they have been shortened\n",
+ " sorted_domains = sorted(self.shortened_links.items(), key=lambda x: x[1], reverse=True)\n",
+ " # return the top n domains\n",
+ " return sorted_domains[:n]\n"
+ ],
+ "metadata": {
+ "id": "9FDajndyNPpH"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "metrics_api = ShortenerMetricsAPI()\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=E6GPMTDx41Y\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=U8_YEWuBybI\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=ZSiXZxVpVhs\")\n",
+ "metrics_api.add_shortened_link(\"https://www.youtube.com/watch?v=vYCjjAz3UD0\")\n",
+ "metrics_api.add_shortened_link(\"https://stackoverflow.blog/2021/12/30/how-often-do-people-actually-copy-and-paste-from-stack-overflow-now-we-know/\")\n",
+ "metrics_api.add_shortened_link(\"https://en.wikipedia.org/wiki/Artificial_Intelligence_Markup_Language\")\n",
+ "metrics_api.add_shortened_link(\"https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/?ranMID=39197&ranEAID=yNfEamYSgXk&ranSiteID=yNfEamYSgXk-FaJv9m4qNyvV_Sf4.6AWTw&LSNPUBID=yNfEamYSgXk&utm_source=aff-campaign&utm_medium=udemyads\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/the-complete-web-development-bootcamp/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/100-days-of-code/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/aws-certified-cloud-practitioner-new/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/aws-certified-solutions-architect-associate-saa-c03/\")\n",
+ "metrics_api.add_shortened_link(\"https://www.udemy.com/course/react-the-complete-guide-incl-redux/\")\n",
+ "\n",
+ "top_domains = metrics_api.get_top_domains()\n",
+ "for domain, count in top_domains:\n",
+ " print(f\"{domain}: {count}\")"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "MOO0koj2bUzR",
+ "outputId": "24632f0a-8872-46ba-f01e-9e9889f2b57a"
+ },
+ "execution_count": null,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "www.udemy.com: 6\n",
+ "www.youtube.com: 4\n",
+ "en.wikipedia.org: 2\n"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
From a91d509f328d4822bb6c7d79609ad3e14d034fe8 Mon Sep 17 00:00:00 2001
From: "Dr. Mudasar Pasha B A" <100229549+mudasargmit@users.noreply.github.com>
Date: Fri, 12 May 2023 06:15:45 +0530
Subject: [PATCH 12/12] Created using Colaboratory