Skip to content

Commit 2c1c333

Browse files
committed
Added script with bs4
1 parent 06ca991 commit 2c1c333

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Python/bitcoin-price/README.md

Whitespace-only changes.

Python/bitcoin-price/current_price.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import requests
2+
from bs4 import BeautifulSoup as BS
3+
4+
# We are basically getting the URL of coinmarket camp and scraping it's content
5+
soup = BS(requests.get('https://coinmarketcap.com/currencies/bitcoin/').content, features="lxml")
6+
7+
# Here we are searching for the corresponding div in which span class is present
8+
# then we need to extract the span class
9+
div = soup.find("div", {"class" : "f6l7tu-0 cdygDb cmc-details-panel-price"
10+
}).find("span", {"class" : "cmc-details-panel-price__price"})
11+
12+
# Now we print all elements extracted from div
13+
for i in div:
14+
print(i)

0 commit comments

Comments
 (0)