Created
May 6, 2020 01:23
-
-
Save ejs94/5657d676bd47f855ab11a9b9b7646515 to your computer and use it in GitHub Desktop.
Scrapping_Corona.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "name": "Scrapping_Corona.ipynb", | |
| "provenance": [], | |
| "collapsed_sections": [], | |
| "authorship_tag": "ABX9TyNoUlr4AxPf3JcCG2jAMqJJ", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/ejs94/5657d676bd47f855ab11a9b9b7646515/scrapping_corona.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "GuU_bG0OsoAn", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "import requests\n", | |
| "from bs4 import BeautifulSoup" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "jcfAoPWSsvV_", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "url = \"https://www.worldometers.info/coronavirus/\"" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "jUTLx6aUtZpA", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "r = requests.get(url)\n", | |
| "s = BeautifulSoup(r.text,\"html.parser\")\n", | |
| "data = s.find_all(\"div\",class_ = \"maincounter-number\")" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "LiHaYKNst6PR", | |
| "colab_type": "code", | |
| "outputId": "6e0fda22-ac51-41ab-fc4a-6277ccde6a58", | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 73 | |
| } | |
| }, | |
| "source": [ | |
| "print(\"Total Cases :\",data[0].text.strip())\n", | |
| "print(\"Total Deaths :\",data[1].text.strip())\n", | |
| "print(\"Total Recovered :\",data[2].text.strip())" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": [ | |
| "Total Cases : 3,724,511\n", | |
| "Total Deaths : 258,026\n", | |
| "Total Recovered : 1,239,994\n" | |
| ], | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "KJliAy88uUhv", | |
| "colab_type": "code", | |
| "colab": {} | |
| }, | |
| "source": [ | |
| "" | |
| ], | |
| "execution_count": 0, | |
| "outputs": [] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment