Step 1: Library Installations
* pip install bs4
* pip install requests
Step 2: Importing Libraries
import requests
from bs4 import BeautifulSoup as bs
from bs4 import BeautifulSoup as bs
Step 3: Requesting the URL
url='https://www.coindesk.com/price/bitcoin'
r=requests.get(url)
r=requests.get(url)
Step 4: Extracting the contents in Html form
soup=bs(r.content,'html.parser')
Step 5: Extracting the prices
price=soup.find('div',{'class':'price-large'})
print("bitcoin:",price.text)
Step 6: Whether its price is increasing or Decreasing
percent=soup.find('span',{'class':'percent-value-text'})
percentage=float(percent.text)
if percentage>0:
print('bitcoin increased today')
else:
print('bitcoin decreased today')
percentage=float(percent.text)
if percentage>0:
print('bitcoin increased today')
else:
print('bitcoin decreased today')
For more clear understandings of code then check out this video..!
(If video not displayed below change into web version )
No comments:
Post a Comment