diff --git a/01_Billboard.ipynb b/01_Billboard.ipynb index 779a38c..f7a42c6 100644 --- a/01_Billboard.ipynb +++ b/01_Billboard.ipynb @@ -8,7 +8,7 @@ }, "source": [ "

Table of Contents

\n", - "
" + "
" ] }, { @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "promotional-algorithm", "metadata": {}, "outputs": [], @@ -59,12 +59,66 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "civic-broad", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r = requests.get(\"https://www.billboard.com/charts/hot-100\")\n", + "r.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "46510387", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Date': 'Sat, 09 Oct 2021 08:24:29 GMT', 'Content-Type': 'text/html; charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'CF-Ray': '69b636812a885941-AMS', 'Age': '165', 'Cache-Control': 'max-age=1, public, s-maxage=300', 'Set-Cookie': 'PGMINFO=cc:nl-ip:82.217.46.140; Max-Age=3600; Path=/; Domain=.billboard.com, __cf_bm=QnxRpRp3FfJGDqN.bwtkxvaJbRAAlAZrMf0j9nbaimI-1633767869-0-AUonlb89oNYOtFQF1MpubQO4FPh1+OMptFQb5ABEs0tEy7WIY3+MfB5686Nn7yRiLriqBrx/sj+7rDBhQZSNWIdHa/y7QKUlaUPabivIlNhJ; path=/; expires=Sat, 09-Oct-21 08:54:29 GMT; domain=.billboard.com; HttpOnly; Secure; SameSite=None', 'Vary': 'Accept-Encoding', 'CF-Cache-Status': 'HIT', 'Expect-CT': 'max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"', 'X-Trace': '2B116C4ED9798929E28FE7684FC5042FCB45C878CCC0EFEBCB4FAC7A0800', 'Server': 'cloudflare', 'Content-Encoding': 'gzip', 'alt-svc': 'h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400'}" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "r.headers" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "bd1fd818", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# 200 status code means OK!" + "r.cookies" ] }, { @@ -77,11 +131,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "revised-digest", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "soup = BeautifulSoup(r.content, 'html.parser')" + ] }, { "cell_type": "markdown", @@ -93,20 +149,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "falling-chambers", "metadata": {}, "outputs": [], "source": [ "# song titles\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", + "last_week_ranks = soup.find_all(\"span\", class_= \"chart-element__meta text--center color--secondary text--last\")\n", "\n", "# peak rank\n", + "peak_ranks = soup.find_all(\"span\", class_= \"chart-element__meta text--center color--secondary text--peak\")\n", "\n", - "# weeks on chart\n" + "# weeks on chart\n", + "weeks_on_chart = soup.find_all(\"span\", class_= \"chart-element__meta text--center color--secondary text--week\")" ] }, { @@ -119,11 +180,15 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "amateur-protocol", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "for i in [songs, artists, last_week_ranks, peak_ranks, weeks_on_chart]:\n", + " for j in range(len(i)):\n", + " i[j] = i[j].getText()" + ] }, { "cell_type": "markdown", @@ -135,16 +200,193 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "external-instrumentation", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "billboard = pd.DataFrame(\n", + " {\"song\": songs,\n", + " \"artist\": artists,\n", + " \"last_week_rank\": last_week_ranks,\n", + " \"peak_rank\": peak_ranks,\n", + " \"weeks_on_chart\": weeks_on_chart}\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "4f1c4230", + "metadata": { + "scrolled": true + }, + "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": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "billboard" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -158,7 +400,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.9.5" }, "toc": { "base_numbering": 1, diff --git a/02_Further_questions.ipynb b/02_Further_questions.ipynb index 66fb224..61257e2 100644 --- a/02_Further_questions.ipynb +++ b/02_Further_questions.ipynb @@ -8,7 +8,7 @@ }, "source": [ "

Table of Contents

\n", - "
" + "
" ] }, { @@ -29,7 +29,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, + "id": "c61a224e", + "metadata": {}, + "outputs": [], + "source": [ + "from bs4 import BeautifulSoup\n", + "import pandas as pd\n", + "import requests\n", + "from urllib.request import urlopen" + ] + }, + { + "cell_type": "code", + "execution_count": 2, "id": "appreciated-bubble", "metadata": {}, "outputs": [], @@ -37,6 +50,178 @@ "url ='https://en.wikipedia.org/wiki/Python'" ] }, + { + "cell_type": "code", + "execution_count": 3, + "id": "91ccc04e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "#mw-head\n", + "#searchInput\n", + "https://en.wiktionary.org/wiki/Python\n", + "https://en.wiktionary.org/wiki/python\n", + "/wiki/Pythonidae\n", + "/wiki/Python_(genus)\n", + "#Computing\n", + "#People\n", + "#Roller_coasters\n", + "#Vehicles\n", + "#Weaponry\n", + "#Other_uses\n", + "#See_also\n", + "/w/index.php?title=Python&action=edit§ion=1\n", + "/wiki/Python_(programming_language)\n", + "/wiki/CMU_Common_Lisp\n", + "/wiki/PERQ#PERQ_3\n", + "/w/index.php?title=Python&action=edit§ion=2\n", + "/wiki/Python_of_Aenus\n", + "/wiki/Python_(painter)\n", + "/wiki/Python_of_Byzantium\n", + "/wiki/Python_of_Catana\n", + "/wiki/Python_Anghelo\n", + "/w/index.php?title=Python&action=edit§ion=3\n", + "/wiki/Python_(Efteling)\n", + "/wiki/Python_(Busch_Gardens_Tampa_Bay)\n", + "/wiki/Python_(Coney_Island,_Cincinnati,_Ohio)\n", + "/w/index.php?title=Python&action=edit§ion=4\n", + "/wiki/Python_(automobile_maker)\n", + "/wiki/Python_(Ford_prototype)\n", + "/w/index.php?title=Python&action=edit§ion=5\n", + "/wiki/Python_(missile)\n", + "/wiki/Python_(nuclear_primary)\n", + "/wiki/Colt_Python\n", + "/w/index.php?title=Python&action=edit§ion=6\n", + "/wiki/PYTHON\n", + "/wiki/Python_(film)\n", + "/wiki/Python_(mythology)\n", + "/wiki/Monty_Python\n", + "/wiki/Python_(Monty)_Pictures\n", + "/w/index.php?title=Python&action=edit§ion=7\n", + "/wiki/Cython\n", + "/wiki/Pyton\n", + "/wiki/Pithon\n", + "/wiki/File:Disambig_gray.svg\n", + "/wiki/Help:Disambiguation\n", + "https://en.wikipedia.org/w/index.php?title=Special:WhatLinksHere/Python&namespace=0\n", + "https://en.wikipedia.org/w/index.php?title=Python&oldid=1048703433\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", + "/w/index.php?title=Special:CreateAccount&returnto=Python\n", + "/w/index.php?title=Special:UserLogin&returnto=Python\n", + "/wiki/Python\n", + "/wiki/Talk:Python\n", + "/wiki/Python\n", + "/w/index.php?title=Python&action=edit\n", + "/w/index.php?title=Python&action=history\n", + "/wiki/Main_Page\n", + "/wiki/Main_Page\n", + "/wiki/Wikipedia:Contents\n", + "/wiki/Portal:Current_events\n", + "/wiki/Special:Random\n", + "/wiki/Wikipedia:About\n", + "//en.wikipedia.org/wiki/Wikipedia:Contact_us\n", + "https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en\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/Wikipedia:File_Upload_Wizard\n", + "/wiki/Special:SpecialPages\n", + "/w/index.php?title=Python&oldid=1048703433\n", + "/w/index.php?title=Python&action=info\n", + "/w/index.php?title=Special:CiteThisPage&page=Python&id=1048703433&wpFormIdentifier=titleform\n", + "https://www.wikidata.org/wiki/Special:EntityPage/Q747452\n", + "/w/index.php?title=Special:DownloadAsPdf&page=Python&action=show-download-screen\n", + "/w/index.php?title=Python&printable=yes\n", + "https://commons.wikimedia.org/wiki/Category:Python\n", + "https://af.wikipedia.org/wiki/Python\n", + "https://als.wikipedia.org/wiki/Python\n", + "https://ar.wikipedia.org/wiki/%D8%A8%D8%A7%D9%8A%D8%AB%D9%88%D9%86_(%D8%AA%D9%88%D8%B6%D9%8A%D8%AD)\n", + "https://az.wikipedia.org/wiki/Python\n", + "https://bn.wikipedia.org/wiki/%E0%A6%AA%E0%A6%BE%E0%A6%87%E0%A6%A5%E0%A6%A8_(%E0%A6%A6%E0%A7%8D%E0%A6%AC%E0%A7%8D%E0%A6%AF%E0%A6%B0%E0%A7%8D%E0%A6%A5%E0%A6%A4%E0%A6%BE_%E0%A6%A8%E0%A6%BF%E0%A6%B0%E0%A6%B8%E0%A6%A8)\n", + "https://be.wikipedia.org/wiki/Python\n", + "https://bg.wikipedia.org/wiki/%D0%9F%D0%B8%D1%82%D0%BE%D0%BD_(%D0%BF%D0%BE%D1%8F%D1%81%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5)\n", + "https://cs.wikipedia.org/wiki/Python_(rozcestn%C3%ADk)\n", + "https://da.wikipedia.org/wiki/Python\n", + "https://de.wikipedia.org/wiki/Python\n", + "https://eo.wikipedia.org/wiki/Pitono_(apartigilo)\n", + "https://eu.wikipedia.org/wiki/Python_(argipena)\n", + "https://fa.wikipedia.org/wiki/%D9%BE%D8%A7%DB%8C%D8%AA%D9%88%D9%86\n", + "https://fr.wikipedia.org/wiki/Python\n", + "https://ko.wikipedia.org/wiki/%ED%8C%8C%EC%9D%B4%EC%84%A0\n", + "https://hr.wikipedia.org/wiki/Python_(razdvojba)\n", + "https://io.wikipedia.org/wiki/Pitono\n", + "https://id.wikipedia.org/wiki/Python\n", + "https://ia.wikipedia.org/wiki/Python_(disambiguation)\n", + "https://is.wikipedia.org/wiki/Python_(a%C3%B0greining)\n", + "https://it.wikipedia.org/wiki/Python_(disambigua)\n", + "https://he.wikipedia.org/wiki/%D7%A4%D7%99%D7%AA%D7%95%D7%9F\n", + "https://ka.wikipedia.org/wiki/%E1%83%9E%E1%83%98%E1%83%97%E1%83%9D%E1%83%9C%E1%83%98_(%E1%83%9B%E1%83%A0%E1%83%90%E1%83%95%E1%83%90%E1%83%9A%E1%83%9B%E1%83%9C%E1%83%98%E1%83%A8%E1%83%95%E1%83%9C%E1%83%94%E1%83%9A%E1%83%9D%E1%83%95%E1%83%90%E1%83%9C%E1%83%98)\n", + "https://kg.wikipedia.org/wiki/Mboma_(nyoka)\n", + "https://la.wikipedia.org/wiki/Python_(discretiva)\n", + "https://lb.wikipedia.org/wiki/Python\n", + "https://hu.wikipedia.org/wiki/Python_(egy%C3%A9rtelm%C5%B1s%C3%ADt%C5%91_lap)\n", + "https://mr.wikipedia.org/wiki/%E0%A4%AA%E0%A4%BE%E0%A4%AF%E0%A4%A5%E0%A5%89%E0%A4%A8_(%E0%A4%86%E0%A4%9C%E0%A5%8D%E0%A4%9E%E0%A4%BE%E0%A4%B5%E0%A4%B2%E0%A5%80_%E0%A4%AD%E0%A4%BE%E0%A4%B7%E0%A4%BE)\n", + "https://nl.wikipedia.org/wiki/Python\n", + "https://ja.wikipedia.org/wiki/%E3%83%91%E3%82%A4%E3%82%BD%E3%83%B3\n", + "https://no.wikipedia.org/wiki/Pyton\n", + "https://pl.wikipedia.org/wiki/Pyton\n", + "https://pt.wikipedia.org/wiki/Python_(desambigua%C3%A7%C3%A3o)\n", + "https://ru.wikipedia.org/wiki/Python_(%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D1%8F)\n", + "https://sk.wikipedia.org/wiki/Python\n", + "https://sr.wikipedia.org/wiki/%D0%9F%D0%B8%D1%82%D0%BE%D0%BD_(%D0%B2%D0%B8%D1%88%D0%B5%D0%B7%D0%BD%D0%B0%D1%87%D0%BD%D0%B0_%D0%BE%D0%B4%D1%80%D0%B5%D0%B4%D0%BD%D0%B8%D1%86%D0%B0)\n", + "https://sh.wikipedia.org/wiki/Python\n", + "https://fi.wikipedia.org/wiki/Python\n", + "https://sv.wikipedia.org/wiki/Pyton\n", + "https://th.wikipedia.org/wiki/%E0%B9%84%E0%B8%9E%E0%B8%97%E0%B8%AD%E0%B8%99\n", + "https://tr.wikipedia.org/wiki/Python\n", + "https://uk.wikipedia.org/wiki/%D0%9F%D1%96%D1%84%D0%BE%D0%BD\n", + "https://ur.wikipedia.org/wiki/%D9%BE%D8%A7%D8%A6%DB%8C%D8%AA%DA%BE%D9%88%D9%86\n", + "https://vi.wikipedia.org/wiki/Python\n", + "https://zh.wikipedia.org/wiki/Python_(%E6%B6%88%E6%AD%A7%E4%B9%89)\n", + "https://www.wikidata.org/wiki/Special:EntityPage/Q747452#sitelinks-wikipedia\n", + "//en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License\n", + "//creativecommons.org/licenses/by-sa/3.0/\n", + "//foundation.wikimedia.org/wiki/Terms_of_Use\n", + "//foundation.wikimedia.org/wiki/Privacy_policy\n", + "//www.wikimediafoundation.org/\n", + "https://foundation.wikimedia.org/wiki/Privacy_policy\n", + "/wiki/Wikipedia:About\n", + "/wiki/Wikipedia:General_disclaimer\n", + "//en.wikipedia.org/wiki/Wikipedia:Contact_us\n", + "//en.m.wikipedia.org/w/index.php?title=Python&mobileaction=toggle_view_mobile\n", + "https://www.mediawiki.org/wiki/Special:MyLanguage/How_to_contribute\n", + "https://stats.wikimedia.org/#/en.wikipedia.org\n", + "https://foundation.wikimedia.org/wiki/Cookie_statement\n", + "https://wikimediafoundation.org/\n", + "https://www.mediawiki.org/\n" + ] + } + ], + "source": [ + "html = urlopen(url)\n", + "bsObj = BeautifulSoup(html)\n", + "for link in bsObj.findAll(\"a\"):\n", + " if 'href' in link.attrs:\n", + " print(link.attrs['href'])" + ] + }, { "cell_type": "markdown", "id": "relevant-performer", @@ -47,12 +232,72 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "scenic-surgeon", "metadata": {}, "outputs": [], "source": [ - "url = 'http://uscode.house.gov/download/download.shtml'" + "url_2 = 'http://uscode.house.gov/download/download.shtml'" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "2ac30d9e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "response = requests.get(url_2)\n", + "response.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "cd8e4a20", + "metadata": {}, + "outputs": [], + "source": [ + "soup = BeautifulSoup(response.content, \"html.parser\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "689a9068", + "metadata": {}, + "outputs": [], + "source": [ + "changed = soup.find_all(\"div\", class_=\"usctitlechanged\")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "aab8cf6c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + } + ], + "source": [ + "print(len(changed))" ] }, { @@ -65,12 +310,157 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "starting-blackberry", "metadata": {}, "outputs": [], "source": [ - "url = 'https://www.fbi.gov/wanted/topten" + "url_3 = 'https://www.fbi.gov/wanted/topten'" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "e730f893", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fbi_wanted = requests.get(url_3)\n", + "fbi_wanted.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "959619b6", + "metadata": {}, + "outputs": [], + "source": [ + "soup_fbi = BeautifulSoup(fbi_wanted.content, \"html.parser\")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "65ac818b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[

Most Wanted

,\n", + "

\n", + " JASON DEREK BROWN\n", + "

,\n", + "

\n", + " ALEXIS FLORES\n", + "

,\n", + "

\n", + " JOSE RODOLFO VILLARREAL-HERNANDEZ\n", + "

,\n", + "

\n", + " OCTAVIANO JUAREZ-CORRO\n", + "

,\n", + "

\n", + " EUGENE PALMER\n", + "

,\n", + "

\n", + " RAFAEL CARO-QUINTERO\n", + "

,\n", + "

\n", + " BHADRESHKUMAR CHETANBHAI PATEL\n", + "

,\n", + "

\n", + " ALEJANDRO ROSALES CASTILLO\n", + "

,\n", + "

\n", + " ROBERT WILLIAM FISHER\n", + "

,\n", + "

\n", + " ARNOLDO JIMENEZ\n", + "

]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "soup_fbi.find_all(class_=\"title\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "e72418c9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Most Wanted\n", + "\n", + "JASON DEREK BROWN\n", + "\n", + "\n", + "ALEXIS FLORES\n", + "\n", + "\n", + "JOSE RODOLFO VILLARREAL-HERNANDEZ\n", + "\n", + "\n", + "OCTAVIANO JUAREZ-CORRO\n", + "\n", + "\n", + "EUGENE PALMER\n", + "\n", + "\n", + "RAFAEL CARO-QUINTERO\n", + "\n", + "\n", + "BHADRESHKUMAR CHETANBHAI PATEL\n", + "\n", + "\n", + "ALEJANDRO ROSALES CASTILLO\n", + "\n", + "\n", + "ROBERT WILLIAM FISHER\n", + "\n", + "\n", + "ARNOLDO JIMENEZ\n", + "\n" + ] + } + ], + "source": [ + "for h in soup_fbi.find_all(class_=\"title\"):\n", + " names = h.get_text()\n", + " print(names)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "cbe26e8c", + "metadata": {}, + "outputs": [], + "source": [ + "# TWO PROBLEMS:\n", + "#1. I cannot seem to get rid of the \"most wanted\" at the beginning??\n", + "#2. Its not a list" ] }, { @@ -83,12 +473,98 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "copyrighted-taiwan", "metadata": {}, "outputs": [], "source": [ - "url = 'https://www.emsc-csem.org/Earthquake/'" + "url_4 = 'https://www.emsc-csem.org/Earthquake/'" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "6e8426a5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "200" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "earthquakes = requests.get(url_4)\n", + "earthquakes.status_code" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "67877d43", + "metadata": {}, + "outputs": [], + "source": [ + "soup_eq = BeautifulSoup(earthquakes.content, \"html.parser\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "718f6977", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[04min ago,\n", + " 17min ago,\n", + " 17min ago,\n", + " 25min ago,\n", + " 38min ago,\n", + " 42min ago,\n", + " 47min ago,\n", + " 52min ago,\n", + " 53min ago,\n", + " 1hr 03min ago,\n", + " 1hr 04min ago]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "soup_eq.find_all(class_=\"ago\")[0:11]" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "8f021086", + "metadata": {}, + "outputs": [], + "source": [ + "# date\n", + "date = soup.find_all(\"span\", class_=\"tabe\")\n", + "\n", + "# time\n", + "time = soup.find_all()\n", + "\n", + "# latitude\n", + "latitude = soup.find_all(class_= \"tabev1\")\n", + "\n", + "# longitude\n", + "longitude = soup.find_all(class_=\"tabev2\")\n", + "\n", + "# region name\n", + "region = soup.find_all(class_=\"tb_region\")" ] }, { @@ -101,12 +577,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "metric-vertex", "metadata": {}, "outputs": [], "source": [ - "url = 'https://www.wikipedia.org/'" + "url_5 = 'https://www.wikipedia.org/'" ] }, { @@ -119,12 +595,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "actual-parallel", "metadata": {}, "outputs": [], "source": [ - "url = 'https://data.gov.uk/" + "url_6 = 'https://data.gov.uk/'" ] }, { @@ -137,18 +613,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "adaptive-calculator", "metadata": {}, "outputs": [], "source": [ - "url = 'https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers'" + "url_7 = 'https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers'" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ae079bd", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -162,7 +646,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.9.5" }, "toc": { "base_numbering": 1,