In this article we will see how we can get the current price of the bit coin. Bitcoin is a cryptocurrency. It is a decentralized digital currency without a central bank or single administrator that can be sent from user to user on the peer-to-peer bitcoin network without the need for intermediaries. Modules required and Installation: Requests : Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs.
pip install requests
Beautiful Soup: Beautiful Soup is a library that makes it easy to scrape information from web pages. It sits atop an HTML or XML parser, providing Pythonic idioms for iterating, searching, and modifying the parse tree.
pip install beautifulsoup4
Explanation – We have the google search URL of the bit coin price from that we have scrape the price of the bitcoin in Indian rupees and stored it in a variable, which we further print it.
Python3
from bs4 import BeautifulSoup as BS
import requests
def get_price(url):
data = requests.get(url)
soup = BS(data.text, 'html.parser' )
ans = soup.find( "div" , class_ = "BNeawe iBp4i AP7Wnd" ).text
return ans
ans = get_price(url)
print (ans)
|
Output :
520, 106.95 Indian Rupee