Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions BinancePriceScrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import requests, json

BINANCE_ENDPOINT="https://www.binance.com/bapi/composite/v1/public/marketing/symbol/list"

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)
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# 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/)

* [rich](https://rich.readthedocs.io/en/stable/introduction.html)[for updatedcryptoprice.py]
24 changes: 24 additions & 0 deletions distro_ranking.py
Original file line number Diff line number Diff line change
@@ -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}")
31 changes: 31 additions & 0 deletions updatedcryptoprice.py
Original file line number Diff line number Diff line change
@@ -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)