Skip to content
Advertisement

Scrape Historical Bitcoin Data from Coinmarketcap with BeautifulSoup

I’m trying to scrape Historical Bitcoin Data from coinmarketcap.com in order to get close, volume, date, high and low values since the beginning of the year until Sep 30, 2021. After going through threads and videos for hours, and I’m new to scraping with Python, I don’t know what my mistake is (or is there something with the website I don’t detect?). The following is my code:

JavaScript

As a result I only get:

JavaScript

The task obliges me to scrape with BeautifulSoup and then export to csv (which obviously then is simply df.to_csv – can somebody help me out? That would be highly appreciated.

Advertisement

Answer

Actually, data is loaded dynamically by javascript from api calls json response. So you can grab data easily as follows:

Code:

JavaScript

Output:

JavaScript
Advertisement