From 189b4b260cf03f764861ea6837c55fa375393629 Mon Sep 17 00:00:00 2001 From: Muhammad Ibrahim Date: Thu, 21 Nov 2024 19:22:07 +0530 Subject: [PATCH] Added a webscraping website for Hacker News --- .../bs4-start/__MACOSX/._bs4-start | Bin 0 -> 276 bytes .../bs4-start/__MACOSX/bs4-start/._main.py | Bin 0 -> 332 bytes .../__MACOSX/bs4-start/._website.html | Bin 0 -> 491 bytes .../bs4-start/bs4-start/main.py | 31 ++++++++++++++++++ .../bs4-start/bs4-start/website.html | 26 +++++++++++++++ 5 files changed, 57 insertions(+) create mode 100755 Web Development Python Projects/bs4-start/__MACOSX/._bs4-start create mode 100644 Web Development Python Projects/bs4-start/__MACOSX/bs4-start/._main.py create mode 100644 Web Development Python Projects/bs4-start/__MACOSX/bs4-start/._website.html create mode 100644 Web Development Python Projects/bs4-start/bs4-start/main.py create mode 100644 Web Development Python Projects/bs4-start/bs4-start/website.html diff --git a/Web Development Python Projects/bs4-start/__MACOSX/._bs4-start b/Web Development Python Projects/bs4-start/__MACOSX/._bs4-start new file mode 100755 index 0000000000000000000000000000000000000000..4595b1130b758c71329c760ceb8a1719b64402de GIT binary patch literal 276 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}@gpDx@)<>dG!eitBqRu;46I`dkez_0 z4P-h<+=GFEKRG{FFR`E?Csi*uF*ygK@DGrZU|;KY#f{G?7Xc>KhnX7+RZ|B^w)B7@Jx$Vqox1Ojhs@R)|o50+1L3ClDJkFfd91X&|4`2S^hE9795aAj-fx?f}^Z zXxf;8e2};R1A|m@ey(0(K|xNcUQS|hNojFvN=jl$s&YUuRL>hA?ZLpnk5HGJn4ANa zWHbR%5)2HY2)V-2#G=H!lFYnRhI)y^X&_~Or>+6*VPIfmh?tf%ktxm5VdHfb*{`+l hYC)o;gF<}+0}DfIGqYr4LknY5Yv+uj{M=M)1_0m^F}(l) literal 0 HcmV?d00001 diff --git a/Web Development Python Projects/bs4-start/__MACOSX/bs4-start/._website.html b/Web Development Python Projects/bs4-start/__MACOSX/bs4-start/._website.html new file mode 100644 index 0000000000000000000000000000000000000000..2905b4839b0b825315bae400fed82272be8340a5 GIT binary patch literal 491 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFfi@}(m+1rYamSoa103vf+z#&U{nCI zPXjSBV1bGYFfd3Z=jZAr78K;9>g6OBmy{N#rlcg6q$&plLo_fN0BH{f27ZLP+{EM@ zuq0yzkcwnrFh`P0ElC9GPqfPRb@53|O3jH+H7z!+GBPr%%E-$zGciw3swz&dFiJ_z zNQ9Vi5lBffFo+_|C@f7ZO3W+C%u8kXGw(ziNSWeKF>Vme#vm4-xcBW*_jet8e~k`6xgM{R7p)A!yp{@(hf!BV^bXFPW?tSXbOPT1+7<38m=RL_y};uX!4q9>>S zJyTm^WNLrH@n!gi9kR2E!&wil-gIP_=_#u`J!!sM6V7k{f8|+m?(cI69w94Q3-t{Q aEDWv9%#w`_Ez%OLLsBbBTvIYjtQi1+w|K<> literal 0 HcmV?d00001 diff --git a/Web Development Python Projects/bs4-start/bs4-start/main.py b/Web Development Python Projects/bs4-start/bs4-start/main.py new file mode 100644 index 0000000..d1995ad --- /dev/null +++ b/Web Development Python Projects/bs4-start/bs4-start/main.py @@ -0,0 +1,31 @@ +from bs4 import BeautifulSoup +import requests + +response = requests.get("https://appbrewery.github.io/news.ycombinator.com/") +yc_web_page = response.text + +soup = BeautifulSoup(yc_web_page, "html.parser") +articles = soup.find_all(name="a", class_="storylink") + +article_texts = [] +article_links = [] + +for article_tag in articles: + text = article_tag.getText() + article_texts.append(text) + link = article_tag.get("href") + article_links.append(link) + +article_upvotes = [int(score.getText().split()[0]) for score in soup.find_all(name="span", class_="score")] + +largest_number = max(article_upvotes) +largest_index = article_upvotes.index(largest_number) + +print(article_texts[largest_index]) +print(article_links[largest_index]) +print(article_upvotes[largest_index]) + +# print(article_texts) +# print(article_links) +# print(article_upvotes) + diff --git a/Web Development Python Projects/bs4-start/bs4-start/website.html b/Web Development Python Projects/bs4-start/bs4-start/website.html new file mode 100644 index 0000000..ce4dfbb --- /dev/null +++ b/Web Development Python Projects/bs4-start/bs4-start/website.html @@ -0,0 +1,26 @@ + + + + + + Angela's Personal Site + + + +

Angela Yu

+

Founder of The App Brewery.

+

I am an iOS and Web Developer. I love coffee and motorcycles.

+
+

Books and Teaching

+
    +
  • The Complete iOS App Development Bootcamp
  • +
  • The Complete Web Development Bootcamp
  • +
  • 100 Days of Code - The Complete Python Bootcamp
  • +
+
+

Other Pages

+ My Hobbies + Contact Me + + + \ No newline at end of file