diff --git a/01_Billboard.ipynb b/01_Billboard.ipynb index 779a38c..3fba741 100644 --- a/01_Billboard.ipynb +++ b/01_Billboard.ipynb @@ -2,18 +2,16 @@ "cells": [ { "cell_type": "markdown", - "id": "adequate-aurora", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", - "
" + "
" ] }, { "cell_type": "markdown", - "id": "together-terminology", "metadata": {}, "source": [ "## Import libraries" @@ -22,7 +20,6 @@ { "cell_type": "code", "execution_count": 1, - "id": "little-prophet", "metadata": {}, "outputs": [], "source": [ @@ -33,7 +30,6 @@ }, { "cell_type": "markdown", - "id": "political-wright", "metadata": {}, "source": [ "## Store the hot-100 songs list from billboard url in a variable" @@ -41,8 +37,7 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "promotional-algorithm", + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -51,16 +46,35 @@ }, { "cell_type": "markdown", - "id": "indian-fossil", "metadata": {}, "source": [ "## Download html with a get request" ] }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response = requests.get(url)\n", + "response.status_code" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "civic-broad", "metadata": {}, "outputs": [], "source": [ @@ -69,7 +83,6 @@ }, { "cell_type": "markdown", - "id": "arbitrary-patrick", "metadata": {}, "source": [ "## Parse html (create the 'soup')" @@ -77,15 +90,15 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "revised-digest", + "execution_count": 4, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "soup = BeautifulSoup(response.content, \"html.parser\")" + ] }, { "cell_type": "markdown", - "id": "damaged-watts", "metadata": {}, "source": [ "## Retrieve/extract the desired info" @@ -93,25 +106,32 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "falling-chambers", + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# song titles\n", "\n", + "songs = soup.find_all(\"span\", class_=\"chart-element__information__song text--truncate color--primary\")\n", + "\n", "# artists\n", + "artists = soup.find_all(\"span\", class_=\"chart-element__information__artist text--truncate color--secondary\")\n", "\n", "# last week\n", "\n", + "last_week_rank = soup.find_all(\"span\", class_= \"chart-element__meta text--center color--secondary text--last\")\n", + "\n", "# peak rank\n", "\n", - "# weeks on chart\n" + "peak_rank = soup.find_all(\"span\", class_= \"chart-element__meta text--center color--secondary text--peak\")\n", + "\n", + "# weeks on chart\n", + "\n", + "weeks_on_chart = soup.find_all(\"span\", class_= \"chart-element__meta text--center color--secondary text--week\")\n" ] }, { "cell_type": "markdown", - "id": "employed-chemistry", "metadata": {}, "source": [ "## Get the text" @@ -119,27 +139,290 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "amateur-protocol", + "execution_count": 14, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "for i in [songs, artists, last_week_rank, peak_rank, weeks_on_chart]:\n", + " for j in range(len(i)):\n", + " i[j] = i[j].getText()" + ] }, { "cell_type": "markdown", - "id": "every-degree", "metadata": {}, "source": [ "## Build a dataframe" ] }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "billboard_top100 = pd.DataFrame(\n", + " {\"song\": songs,\n", + " \"artist\": artists,\n", + " \"last_week_rank\": last_week_rank,\n", + " \"peak_rank\": peak_rank,\n", + " \"weeks_on_chart\": weeks_on_chart}\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
songartistlast_week_rankpeak_rankweeks_on_chart
0My UniverseColdplay x BTS-11
1StayThe Kid LAROI & Justin Bieber1112
2Industry BabyLil Nas X & Jack Harlow2210
3Way 2 SexyDrake Featuring Future & Young Thug314
4Fancy LikeWalker Hayes5515
..................
95Pipe DownDrake68144
96Papi's HomeDrake6684
97ChosenBlxst & Tyga Featuring Ty Dolla $ign-981
98Toxic PunkYoungBoy Never Broke Again-991
99MoonKanye West76175
\n", + "

100 rows × 5 columns

\n", + "
" + ], + "text/plain": [ + " song artist last_week_rank \\\n", + "0 My Universe Coldplay x BTS - \n", + "1 Stay The Kid LAROI & Justin Bieber 1 \n", + "2 Industry Baby Lil Nas X & Jack Harlow 2 \n", + "3 Way 2 Sexy Drake Featuring Future & Young Thug 3 \n", + "4 Fancy Like Walker Hayes 5 \n", + ".. ... ... ... \n", + "95 Pipe Down Drake 68 \n", + "96 Papi's Home Drake 66 \n", + "97 Chosen Blxst & Tyga Featuring Ty Dolla $ign - \n", + "98 Toxic Punk YoungBoy Never Broke Again - \n", + "99 Moon Kanye West 76 \n", + "\n", + " peak_rank weeks_on_chart \n", + "0 1 1 \n", + "1 1 12 \n", + "2 2 10 \n", + "3 1 4 \n", + "4 5 15 \n", + ".. ... ... \n", + "95 14 4 \n", + "96 8 4 \n", + "97 98 1 \n", + "98 99 1 \n", + "99 17 5 \n", + "\n", + "[100 rows x 5 columns]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "billboard_top100" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Now I will like to get this weeks's top 50 songs in US from SoundCloud" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "url1 = \"https://soundcloud.com/charts/top?genre=all-music&country=US\"" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response1 = requests.get(url1)\n", + "response1.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [], + "source": [ + "soup = BeautifulSoup(response1.content, \"html.parser\") #parse it" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "expression cannot contain assignment, perhaps you meant \"==\"? (, line 12)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m12\u001b[0m\n\u001b[0;31m week_rank = soup.find_all(\"a href\". class_=\"chartTrack__position sc-font\")\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m expression cannot contain assignment, perhaps you meant \"==\"?\n" + ] + } + ], + "source": [ + "#Retrieving info\n", + "\n", + "# song titles\n", + "\n", + "song_title = soup.find_all(\"a href\", class_=\"sc-link-light sc-link-secondary\")\n", + "\n", + "# artists\n", + "artist = soup.find_all(\"a href\", class_=\"sc-link-dark sc-link-primary\")\n", + "\n", + "# week_rank\n", + "\n", + "week_rank = soup.find_all(\"a href\". class_=\"chartTrack__position sc-font\")\n", + "\n", + "\n", + "\n", + "\n" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "external-instrumentation", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#I'm a bit stuck here, I did try with find_all \"a\" or \"a href\" but did not work. what am I doing wrong?" + ] } ], "metadata": { diff --git a/02_Further_questions.ipynb b/02_Further_questions.ipynb index 66fb224..60106e8 100644 --- a/02_Further_questions.ipynb +++ b/02_Further_questions.ipynb @@ -2,7 +2,6 @@ "cells": [ { "cell_type": "markdown", - "id": "classified-start", "metadata": { "toc": true }, @@ -13,15 +12,25 @@ }, { "cell_type": "markdown", - "id": "cellular-poster", "metadata": {}, "source": [ "As you've seen, scraping the internet is a skill that can get you all sorts of information. Here are some little challenges to gain more experience in the field" ] }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [], + "source": [ + "from bs4 import BeautifulSoup\n", + "import requests\n", + "import pandas as pd\n", + "import re" + ] + }, { "cell_type": "markdown", - "id": "express-introduction", "metadata": {}, "source": [ "### Retrieve an arbitrary Wikipedia page of \"Python\" and create a list of links on that page" @@ -29,17 +38,309 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "appreciated-bubble", + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "url ='https://en.wikipedia.org/wiki/Python'" ] }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response = requests.get(url)\n", + "response.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "soup = BeautifulSoup(response.content, \"html.parser\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[,\n", + " Jump to navigation,\n", + " Jump to search,\n", + " Python,\n", + " python,\n", + " Pythonidae,\n", + " Python (genus),\n", + " 1 Computing,\n", + " 2 People,\n", + " 3 Roller coasters,\n", + " 4 Vehicles,\n", + " 5 Weaponry,\n", + " 6 Other uses,\n", + " 7 See also,\n", + " edit,\n", + " Python (programming language),\n", + " CMU Common Lisp,\n", + " PERQ 3,\n", + " edit,\n", + " Python of Aenus,\n", + " Python (painter),\n", + " Python of Byzantium,\n", + " Python of Catana,\n", + " Python Anghelo,\n", + " edit,\n", + " Python (Efteling),\n", + " Python (Busch Gardens Tampa Bay),\n", + " Python (Coney Island, Cincinnati, Ohio),\n", + " edit,\n", + " Python (automobile maker),\n", + " Python (Ford prototype),\n", + " edit,\n", + " Python (missile),\n", + " Python (nuclear primary),\n", + " Colt Python,\n", + " edit,\n", + " PYTHON,\n", + " Python (film),\n", + " Python (mythology),\n", + " Monty Python,\n", + " Python (Monty) Pictures,\n", + " edit,\n", + " Cython,\n", + " Pyton,\n", + " Pithon,\n", + " \"Disambiguation,\n", + " disambiguation,\n", + " internal link,\n", + " https://en.wikipedia.org/w/index.php?title=Python&oldid=1048703433,\n", + " Categories,\n", + " Disambiguation pages,\n", + " Human name disambiguation pages,\n", + " Disambiguation pages with given-name-holder lists,\n", + " Disambiguation pages with short descriptions,\n", + " Short description is different from Wikidata,\n", + " All article disambiguation pages,\n", + " All disambiguation pages,\n", + " Animal common name disambiguation pages,\n", + " Talk,\n", + " Contributions,\n", + " Create account,\n", + " Log in,\n", + " Article,\n", + " Talk,\n", + " Read,\n", + " Edit,\n", + " View history,\n", + " ,\n", + " Main page,\n", + " Contents,\n", + " Current events,\n", + " Random article,\n", + " About Wikipedia,\n", + " Contact us,\n", + " Donate,\n", + " Help,\n", + " Learn to edit,\n", + " Community portal,\n", + " Recent changes,\n", + " Upload file,\n", + " What links here,\n", + " Related changes,\n", + " Upload file,\n", + " Special pages,\n", + " Permanent link,\n", + " Page information,\n", + " Cite this page,\n", + " Wikidata item,\n", + " Download as PDF,\n", + " Printable version,\n", + " Wikimedia Commons,\n", + " Afrikaans,\n", + " Alemannisch,\n", + " العربية,\n", + " Azərbaycanca,\n", + " বাংলা,\n", + " Беларуская,\n", + " Български,\n", + " Čeština,\n", + " Dansk,\n", + " Deutsch,\n", + " Esperanto,\n", + " Euskara,\n", + " فارسی,\n", + " Français,\n", + " 한국어,\n", + " Hrvatski,\n", + " Ido,\n", + " Bahasa Indonesia,\n", + " Interlingua,\n", + " Íslenska,\n", + " Italiano,\n", + " עברית,\n", + " ქართული,\n", + " Kongo,\n", + " Latina,\n", + " Lëtzebuergesch,\n", + " Magyar,\n", + " मराठी,\n", + " Nederlands,\n", + " 日本語,\n", + " Norsk bokmål,\n", + " Polski,\n", + " Português,\n", + " Русский,\n", + " Slovenčina,\n", + " Српски / srpski,\n", + " Srpskohrvatski / српскохрватски,\n", + " Suomi,\n", + " Svenska,\n", + " ไทย,\n", + " Türkçe,\n", + " Українська,\n", + " اردو,\n", + " Tiếng Việt,\n", + " 中文,\n", + " Edit links,\n", + " Creative Commons Attribution-ShareAlike License,\n", + " ,\n", + " Terms of Use,\n", + " Privacy Policy,\n", + " Wikimedia Foundation, Inc.,\n", + " Privacy policy,\n", + " About Wikipedia,\n", + " Disclaimers,\n", + " Contact Wikipedia,\n", + " Mobile view,\n", + " Developers,\n", + " Statistics,\n", + " Cookie statement,\n", + " \"Wikimedia,\n", + " \"Powered]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wiki_link = soup.find_all(\"a\")\n", + "wiki_link" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/wiki/Pythonidae\n", + "/wiki/Python_(genus)\n", + "/wiki/Python_(programming_language)\n", + "/wiki/CMU_Common_Lisp\n", + "/wiki/PERQ#PERQ_3\n", + "/wiki/Python_of_Aenus\n", + "/wiki/Python_(painter)\n", + "/wiki/Python_of_Byzantium\n", + "/wiki/Python_of_Catana\n", + "/wiki/Python_Anghelo\n", + "/wiki/Python_(Efteling)\n", + "/wiki/Python_(Busch_Gardens_Tampa_Bay)\n", + "/wiki/Python_(Coney_Island,_Cincinnati,_Ohio)\n", + "/wiki/Python_(automobile_maker)\n", + "/wiki/Python_(Ford_prototype)\n", + "/wiki/Python_(missile)\n", + "/wiki/Python_(nuclear_primary)\n", + "/wiki/Colt_Python\n", + "/wiki/PYTHON\n", + "/wiki/Python_(film)\n", + "/wiki/Python_(mythology)\n", + "/wiki/Monty_Python\n", + "/wiki/Python_(Monty)_Pictures\n", + "/wiki/Cython\n", + "/wiki/Pyton\n", + "/wiki/Pithon\n", + "/wiki/File:Disambig_gray.svg\n", + "/wiki/Help:Disambiguation\n", + "/wiki/Help:Category\n", + "/wiki/Category:Disambiguation_pages\n", + "/wiki/Category:Human_name_disambiguation_pages\n", + "/wiki/Category:Disambiguation_pages_with_given-name-holder_lists\n", + "/wiki/Category:Disambiguation_pages_with_short_descriptions\n", + "/wiki/Category:Short_description_is_different_from_Wikidata\n", + "/wiki/Category:All_article_disambiguation_pages\n", + "/wiki/Category:All_disambiguation_pages\n", + "/wiki/Category:Animal_common_name_disambiguation_pages\n", + "/wiki/Special:MyTalk\n", + "/wiki/Special:MyContributions\n", + "/wiki/Python\n", + "/wiki/Talk:Python\n", + "/wiki/Main_Page\n", + "/wiki/Wikipedia:Contents\n", + "/wiki/Portal:Current_events\n", + "/wiki/Special:Random\n", + "/wiki/Wikipedia:About\n", + "/wiki/Help:Contents\n", + "/wiki/Help:Introduction\n", + "/wiki/Wikipedia:Community_portal\n", + "/wiki/Special:RecentChanges\n", + "/wiki/Wikipedia:File_Upload_Wizard\n", + "/wiki/Special:WhatLinksHere/Python\n", + "/wiki/Special:RecentChangesLinked/Python\n", + "/wiki/Special:SpecialPages\n", + "/wiki/Wikipedia:General_disclaimer\n" + ] + } + ], + "source": [ + "def is_valid(url):\n", + " \"\"\"finding the valid link\"\"\"\n", + "\n", + " if url:\n", + " if url.startswith('/wiki/'):\n", + " return True\n", + " return False\n", + "\n", + "\n", + "valid_urls = []\n", + "\n", + "for link in soup.find_all('a'): \n", + " url = link.get('href', '')\n", + " if url not in valid_urls and is_valid(url):\n", + " valid_urls.append(url)\n", + "\n", + "#print(valid_urls)\n", + "\n", + "#for url in valid_urls: \n", + "# print(url)\n", + "\n", + "print('\\n'.join(valid_urls))" + ] + }, { "cell_type": "markdown", - "id": "relevant-performer", "metadata": {}, "source": [ "### Find the number of titles that have changed in the United States Code since its last release point" @@ -48,7 +349,6 @@ { "cell_type": "code", "execution_count": null, - "id": "scenic-surgeon", "metadata": {}, "outputs": [], "source": [ @@ -57,7 +357,6 @@ }, { "cell_type": "markdown", - "id": "acute-necessity", "metadata": {}, "source": [ "### Create a Python list with the top ten FBI's Most Wanted names" @@ -65,17 +364,347 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "starting-blackberry", + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ - "url = 'https://www.fbi.gov/wanted/topten" + "url = 'https://www.fbi.gov/wanted/topten'" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response = requests.get(url)\n", + "response.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "soup = BeautifulSoup(response.content, \"html.parser\")" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "An official website of the United States government. Here's how you know\n", + "\n", + "Submit Search\n", + "\n", + "\n", + "\n", + "Search\n", + "FBI\n", + "Most Wanted\n", + "News\n", + "What We Investigate\n", + "Services\n", + "Resources\n", + "Submit a Tip\n", + "About\n", + "Contact Us\n", + "\n", + "Home\n", + "\n", + "\n", + "\n", + "\n", + "Most Wanted\n", + "\n", + "Facebook Icon\n", + "\n", + "\n", + "\n", + "Email Icon\n", + "\n", + "\n", + "\n", + "Twitter Icon\n", + "\n", + "\n", + "\n", + "Youtube Icon\n", + "\n", + "\n", + "\n", + "Flickr Icon\n", + "\n", + "\n", + "\n", + "LinkedIn Icon\n", + "\n", + "\n", + "\n", + "Instagram Icon\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "FBIFederal Bureau of Investigation\n", + "\n", + "Most Wanted\n", + "Ten Most Wanted Fugitives\n", + "Fugitives\n", + "Capitol Violence\n", + "Terrorism\n", + "Kidnappings/Missing Persons\n", + "Parental Kidnappings\n", + "Seeking Info\n", + "Indian Country\n", + "ECAP\n", + "ViCAP\n", + "Bank Robbers\n", + "Ten Most Wanted Fugitives FAQ\n", + "Ten Most Wanted History Pictures\n", + "\n", + "\n", + "\n", + "JASON DEREK BROWN\n", + "\n", + "\n", + "\n", + "ALEXIS FLORES\n", + "\n", + "\n", + "\n", + "JOSE RODOLFO VILLARREAL-HERNANDEZ\n", + "\n", + "\n", + "\n", + "OCTAVIANO JUAREZ-CORRO\n", + "\n", + "\n", + "\n", + "EUGENE PALMER\n", + "\n", + "\n", + "\n", + "RAFAEL CARO-QUINTERO\n", + "\n", + "\n", + "\n", + "BHADRESHKUMAR CHETANBHAI PATEL\n", + "\n", + "\n", + "\n", + "ALEJANDRO ROSALES CASTILLO\n", + "\n", + "\n", + "\n", + "ROBERT WILLIAM FISHER\n", + "\n", + "\n", + "\n", + "ARNOLDO JIMENEZ\n", + "Ten Most Wanted Fugitives FAQ\n", + "Historical Photos of Each Top Ten Fugitive\n", + "60th Anniversary Booklet\n", + "Most Wanted\n", + "Ten Most Wanted\n", + "Fugitives\n", + "Terrorism\n", + "Kidnappings / Missing Persons\n", + "Seeking Information\n", + "Bank Robbers\n", + "ECAP\n", + "ViCAP\n", + "About\n", + "Mission & Priorities\n", + "Leadership & Structure\n", + "Partnerships\n", + "Community Outreach\n", + "FAQs\n", + "News\n", + "Stories\n", + "Videos\n", + "Press Release\n", + "Speeches\n", + "Testimony\n", + "Podcasts and Radio\n", + "Photos\n", + "Español\n", + "Apps\n", + "Resources\n", + "Law Enforcement\n", + "Businesses\n", + "Victim Assistance\n", + "Reports & Publications\n", + "What We Investigate\n", + "Terrorism\n", + "Counterintelligence\n", + "Cyber Crime\n", + "Public Corruption\n", + "Civil Rights\n", + "Organized Crime\n", + "White-Collar Crime\n", + "Violent Crime\n", + "WMD\n", + "Contact Us\n", + "Field Offices\n", + "FBI Headquarters\n", + "Overseas Offices\n", + "Services\n", + "CJIS\n", + "CIRG\n", + "Laboratory Services\n", + "Training Academy\n", + "Operational Technology\n", + "Information Management\n", + "FBI Jobs\n", + "Submit a Tip\n", + "Crime Statistics\n", + "History\n", + "FOIPA\n", + "Scams & Safety\n", + "FBI Kids\n", + "FBI Tour\n", + "Accessibility\n", + "eRulemaking\n", + "Freedom of Information / Privacy Act\n", + "Legal Notices\n", + "Legal Policies & Disclaimers\n", + "Privacy Policy\n", + "USA.gov\n", + "White House\n", + "No FEAR Act\n", + "Equal Opportunity\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "Email updates\n", + "Accessibility\n", + "eRulemaking\n", + "Freedom of Information / Privacy Act\n", + "Legal Notices\n", + "Legal Policies & Disclaimers\n", + "Privacy Policy\n", + "USA.gov\n", + "White House\n", + "No FEAR Act\n", + "Equal Opportunity\n", + "\n", + "FBI.gov is an official site of the U.S. Department of Justice\n", + " © \n", + "\n", + "Home\n", + "Most Wanted\n", + "News\n", + "What We Investigate\n", + "Services\n", + "Resources\n", + "Submit a Tip\n", + "About\n", + "Contact Us\n", + "Crime Statistics\n", + "Photos\n", + "Video\n", + "Outreach\n", + "History\n", + "FOIA\n", + "Scams & Safety\n", + "FBI Kids\n", + "FBI Jobs\n", + "Subscribe\n", + "No Thanks\n" + ] + } + ], + "source": [ + "\n", + "top10_wanted = []\n", + "\n", + "for i in soup.find_all('a', href = True): \n", + " url = i.get_text()\n", + " top10_wanted.append(url)\n", + "\n", + "print('\\n'.join(top10_wanted))\n", + "\n", + "#for a in soup.find_all('a', href =True):\n", + " #print(a.get_text())\n", + "\n", + "\n", + "#not sure how to get the name's only" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "top10_wanted" ] }, { "cell_type": "markdown", - "id": "joined-induction", "metadata": {}, "source": [ "### Display the 20 latest earthquakes info (date, time, latitude, longitude and region name) by the EMSC as a pandas dataframe" @@ -84,7 +713,6 @@ { "cell_type": "code", "execution_count": null, - "id": "copyrighted-taiwan", "metadata": {}, "outputs": [], "source": [ @@ -93,7 +721,6 @@ }, { "cell_type": "markdown", - "id": "dominican-defeat", "metadata": {}, "source": [ "### List all language names and number of related articles in the order they appear in [wikipedia.org](wikipedia.org)" @@ -102,7 +729,6 @@ { "cell_type": "code", "execution_count": null, - "id": "metric-vertex", "metadata": {}, "outputs": [], "source": [ @@ -111,7 +737,6 @@ }, { "cell_type": "markdown", - "id": "split-cartridge", "metadata": {}, "source": [ "### A list with the different kind of datasets available in [data.gov.uk](data.gov.uk)\n" @@ -120,7 +745,6 @@ { "cell_type": "code", "execution_count": null, - "id": "actual-parallel", "metadata": {}, "outputs": [], "source": [ @@ -129,7 +753,6 @@ }, { "cell_type": "markdown", - "id": "potential-malpractice", "metadata": {}, "source": [ "### Display the top 10 languages by number of native speakers stored in a pandas dataframe" @@ -138,7 +761,6 @@ { "cell_type": "code", "execution_count": null, - "id": "adaptive-calculator", "metadata": {}, "outputs": [], "source": [