cft
Become a CreatorSign inGet Started

Extract Bitcoin Price In Realtime

This article talks about how can we read web page and extract current Bitcoin price in real-time.


user

Shweta Lodha

3 months ago | 1 min read
Follow

extract-bitcoin-price-realtime-dnubz

This article talks about how can we read web page and extract current Bitcoin price. Now, to perform this web scrapping, we need few things:

  • Website
  • Web scrapping libraries/tools 
  • Programming language

Website

This is the website from which we are going to read price of Bitcoin. There are many websites, from which you can read this data but for this article, I am using Coinmarketcap.com and it's URL is https://coinmarketcap.com/currencies/bitcoin:

Web Scrapping Libraries/Tools

There are many web scrapping libraries and tools available in market. Below is the list of my recommendations:

  • Beautiful Soup
  • Scrapy
  • Requests (http for humans)
  • LXML
  • Selenium

If you want to know the brief of any of these, you can watch out my video. For this article, I'm using Requests along with Beautiful Soup.

Programing Language

This article uses Python as a programming language

import requests

from bs4 import BeautifulSoup as bs

URL = "

"

reponse = requests.get(URL)

htmlContent = bs(reponse.content,'html.parser')

divTagContent = htmlContent.find('div',{'class':'priceValue'})

priceTag = divTagContent.select_one('span')print(f"Current price of Bitcoin is {priceTag.text}")

To understand, which HTML tag is holding this data, you can use any developer tool. If you have Chrome, then you can open coinmarketcap.com website and press F12. Doing this will open a developer tool window as shown below:

 Hope you enjoyed extracting data from a web page. You can also watch out this implementation in my recording.



Upvote


user
Created by

Shweta Lodha

Follow

C# Corner MVP, Speaker, Blogger, Developer and Data Analyst

I'm Shweta, the C# corner MVP, a speaker and a girl behind http://www.shwetalodha.in. You will find that I'm incredibly passionate about helping people solving their technical problems related to Microsoft Technologies. I won several recognition from very popular forums like MSDN, Microsoft Technet, C# Corner, CodeProject for my community contributions.


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles