You can get the current block number of bitcoin in two ways.
you will need to install the complete bitcoin-core and its data(around 223GB) on your machine and you need to run that bitcoin-core software 24*7 so that it will update the data on your machine and will give you the current block height and its information.
You can download the full bitcoin-core through this link:
Once you download the bitcoin-core, go through the certain command which will help you develop and monitor bitcoin network.
You can find the commands here:
You can directly scrap the data from the bitcoin explorer which gives us the up-to-date information of bitcoin-core networks such as all the transaction and its metadata.
some of the bitcoin explorers are:
To know about data scraping, go through the link: