From 4272b871d794d3a414e6bab9cd0b5191e86c4554 Mon Sep 17 00:00:00 2001 From: Ritik Gulabrani <52580488+ritik047@users.noreply.github.com> Date: Mon, 3 Oct 2022 22:58:59 +0530 Subject: [PATCH 1/8] Update README.md --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a8f139d..54f22f2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # Web-Scraping -Web Scrapping examples using Beautiful Soup and Requests +Web Scrapping examples using Beautiful Soup and Requests. + +Beautiful Soup is a Python library designed for quick turnaround projects like screen-scraping. + +Prerequisites: + +* [Python 3.6+](https://www.python.org/downloads/) + +* [pip](https://pypi.org/project/pip/) + +* [Beautiful Soup 4](https://www.crummy.com/software/BeautifulSoup/) + +* [requests](https://pypi.org/project/requests/) From b6fde212939ffc4d39bf3a31b778db603473cc05 Mon Sep 17 00:00:00 2001 From: Alex Nojenko <93285568+informationvulture@users.noreply.github.com> Date: Mon, 3 Oct 2022 20:27:03 +0000 Subject: [PATCH 2/8] Add distro ranking script --- distro_ranking.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 distro_ranking.py diff --git a/distro_ranking.py b/distro_ranking.py new file mode 100644 index 0000000..105185d --- /dev/null +++ b/distro_ranking.py @@ -0,0 +1,24 @@ +""" +REPO: https://github.com/ritik047/Web-Scraping +DATE: 2022-10-03 +USAGE: Python script for getting the top Linux distros in the last 30 days. +It queries https://distrowatch.com/dwres.php?resource=popularity to get the data. +""" + +# Define imports +from bs4 import BeautifulSoup +import requests + + +# Get the data +r = requests.get("https://distrowatch.com/dwres.php?resource=popularity", timeout=10) +soup = BeautifulSoup(r.content, 'html.parser') +vals = soup.find_all('td', class_="phr2") + +# As BeautifulSoup will return all the distros from all categories, +# we need to select the last 264 values in the last column +last_12_months = vals[792:1056] + +# Print out the data, in order, with it's ranking and name. +for c,v in enumerate(last_12_months): + print(f"{c+1}: {v.text}") From 2715becac0f95a489ab02373f9f3891213d04025 Mon Sep 17 00:00:00 2001 From: Nagesh Naik <72155222+Naik-G@users.noreply.github.com> Date: Sun, 9 Oct 2022 15:28:30 +0530 Subject: [PATCH 3/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 54f22f2..0875221 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,5 @@ Prerequisites: * [Beautiful Soup 4](https://www.crummy.com/software/BeautifulSoup/) * [requests](https://pypi.org/project/requests/) + +* [rich](https://rich.readthedocs.io/en/stable/introduction.html) From 2155eb7a958c85cd8bcfa0d89e35c5820fd8c266 Mon Sep 17 00:00:00 2001 From: Nagesh Naik <72155222+Naik-G@users.noreply.github.com> Date: Mon, 10 Oct 2022 17:21:22 +0530 Subject: [PATCH 4/8] Improved UI Improved UI from cryptoprice.py --- updatedcryptoprice.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 updatedcryptoprice.py diff --git a/updatedcryptoprice.py b/updatedcryptoprice.py new file mode 100644 index 0000000..06c9006 --- /dev/null +++ b/updatedcryptoprice.py @@ -0,0 +1,31 @@ +from bs4 import BeautifulSoup +import requests +from rich.console import Console +from rich.table import Table + +table = Table(title="Coin's Price") + +table.add_column("S. No.", style="cyan", no_wrap=True) +table.add_column("Coin Name", style="magenta") +table.add_column("Price", justify="left", style="green") + +url="https://coinmarketcap.com/" +result=requests.get(url).text +doc=BeautifulSoup(result,"html.parser") + +tbody=doc.tbody +trs=tbody.contents + + +prices=() + +for tr in trs[:10]: +for i,tr in enumerate(trs[:10]): + name,price=tr.contents[2:4] + print(name.p.string) + print(price.a.string) + + table.add_row(str(i+1),name.text,price.text) + +console = Console() +console.print(table) From 35a99ac60e7ba7f668e5b4ce53129084b29477ca Mon Sep 17 00:00:00 2001 From: Ritik Gulabrani <52580488+ritik047@users.noreply.github.com> Date: Tue, 11 Oct 2022 20:41:59 +0530 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0875221..07c9a68 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ Prerequisites: * [requests](https://pypi.org/project/requests/) -* [rich](https://rich.readthedocs.io/en/stable/introduction.html) +* [rich](https://rich.readthedocs.io/en/stable/introduction.html)[for updatedcryptoprice.py] From 17402c8b1d1b05e9cdbb3ac9228ecd15b21c5eb3 Mon Sep 17 00:00:00 2001 From: s Date: Fri, 14 Oct 2022 08:58:18 +0530 Subject: [PATCH 6/8] Added BinancePriceScrapper.py --- BinancePriceScrapper.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 BinancePriceScrapper.py diff --git a/BinancePriceScrapper.py b/BinancePriceScrapper.py new file mode 100644 index 0000000..00719f8 --- /dev/null +++ b/BinancePriceScrapper.py @@ -0,0 +1,13 @@ +import requests, json + +BINANCE_ENDPOINT="https://www.binance.com/bapi/composite/v1/public/marketing/symbol/list" + +response = requests.get(BINANCE_ENDPOINT) + +if response.status_code==200: + for asset in json.loads(response.text).get("data"): + print("NAME: {}\nSYMBOL: {}\nPRICE: {}\nTOTAL-SUPPLY: {}\n24HRS-PRICE-CHANGE: {}\n24HRS-PERCENT-CHANGE: {}" + .format(asset.get("name"), asset.get("symbol"), asset.get("price"), asset.get("totalSupply"), asset.get("dayChange"), asset.get("dayChangeAmount")), end="\n"+"="*100+"\n") + +else: + print("Oop! something went wrong status code: ", response.status_code) \ No newline at end of file From 51234ec42f2dcfa5b88612c6b9ea7192758fd8ce Mon Sep 17 00:00:00 2001 From: s Date: Fri, 14 Oct 2022 08:58:18 +0530 Subject: [PATCH 7/8] Added BinancePriceScrapper.py @hacktoberfest-accepted --- BinancePriceScrapper.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 BinancePriceScrapper.py diff --git a/BinancePriceScrapper.py b/BinancePriceScrapper.py new file mode 100644 index 0000000..00719f8 --- /dev/null +++ b/BinancePriceScrapper.py @@ -0,0 +1,13 @@ +import requests, json + +BINANCE_ENDPOINT="https://www.binance.com/bapi/composite/v1/public/marketing/symbol/list" + +response = requests.get(BINANCE_ENDPOINT) + +if response.status_code==200: + for asset in json.loads(response.text).get("data"): + print("NAME: {}\nSYMBOL: {}\nPRICE: {}\nTOTAL-SUPPLY: {}\n24HRS-PRICE-CHANGE: {}\n24HRS-PERCENT-CHANGE: {}" + .format(asset.get("name"), asset.get("symbol"), asset.get("price"), asset.get("totalSupply"), asset.get("dayChange"), asset.get("dayChangeAmount")), end="\n"+"="*100+"\n") + +else: + print("Oop! something went wrong status code: ", response.status_code) \ No newline at end of file From 8101a13b6c8ac4a9ba323804b62a322e46f5c09f Mon Sep 17 00:00:00 2001 From: Ritik Gulabrani <52580488+ritik047@users.noreply.github.com> Date: Sat, 15 Oct 2022 01:27:54 +0530 Subject: [PATCH 8/8] Update BinancePriceScrapper.py --- BinancePriceScrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BinancePriceScrapper.py b/BinancePriceScrapper.py index 00719f8..7ef7087 100644 --- a/BinancePriceScrapper.py +++ b/BinancePriceScrapper.py @@ -4,10 +4,13 @@ response = requests.get(BINANCE_ENDPOINT) +i=0 if response.status_code==200: for asset in json.loads(response.text).get("data"): + print(i,end=")") + i=i+1 print("NAME: {}\nSYMBOL: {}\nPRICE: {}\nTOTAL-SUPPLY: {}\n24HRS-PRICE-CHANGE: {}\n24HRS-PERCENT-CHANGE: {}" .format(asset.get("name"), asset.get("symbol"), asset.get("price"), asset.get("totalSupply"), asset.get("dayChange"), asset.get("dayChangeAmount")), end="\n"+"="*100+"\n") else: - print("Oop! something went wrong status code: ", response.status_code) \ No newline at end of file + print("Oop! something went wrong status code: ", response.status_code)