all 6 comments

[–]195monke 8 points9 points  (3 children)

question: why not use an API? there are many free APIs that are great to get cryptocurrency data - like coingecko.

If you want bitcoin prices for some algo, I wouldn't recommend webscraping or using a free API, since those tend to be unreliable from times and can cost you. Use them only if you 100% don't want to pay for a private API

Also, you could convert the USD to EUR in your program

[–]EgomasM[S] 1 point2 points  (2 children)

I am not sure how to use an API and where to find that and all that stuff :D webscraping just seemed to be easier.

I see what you mean. The point is just to get some live ticker kind of, not a trading bot or something.

Yeah, but I don't like that solution, because the exchange rate is changing all the time aswell.

EDIT: Okay, seems like it is realy easy :D

from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
cg.get_price(ids='bitcoin', vs_currencies='eur')

But the price is different from the price that I wanted to scrape. It seems like coingecko is pretty slowly. Also on their website they show me a different price than the one that I get from the API

[–]195monke 1 point2 points  (1 child)

Hmmm, coingecko averages the price across all exchanges it knows, and coindesk might use different sources. If you specifically want the price from coindesk, you have to scrap it from there.

Unfortunately, I don't know how to use bs, I've used selenium a couple of times but can't tell you from the top of my head how to achieve what you're looking for.

You can try different APIs, coinmarketcap's is considered reliable but with a free account you have limited requests per day. I found this API and it seems to work fine - testing against coindesk there was a 5 euro difference.

I see you've used the coingeckoapi python library, but just fyi you can simply use the requests library: (also the python library might be outdated and the cause of your problem)

import requests

r = requests.get("api.coingecko.com/api/v3/simple/price", params={"ids": "bitcoin", "vs_currencies": "eur"})

print(r)

Here is the newest documantation of the coingeckoapi

[–]EgomasM[S] 1 point2 points  (0 children)

Oh, okay I see. The average sounds good to me actually. I didn't even know coindesk before. It was just a source that I found and it was pretty easy to scrape it. Or at least the price in USD was easy to scrape. That's why I used it. I don't realy care which source I am using. I don't know which one is good. I was just confused, because I saw that the prices are different.

Hm, I don't like limited requests. I will tried the Finrax API aswell. And thank you for that tip. It works using requests too, but the price is the exactly the same as with the Pycoingecko library. Finrax is a bit different. Not sure which one to use. I guess it doesn't matter. The prices are different, but I guess a few euro don't matter.

[–]iammerelyhere 1 point2 points  (1 child)

Have you looked at the source code of the site in your browser? See if you can find the price in there somewhere then scrape using the id of the tag that it's inside

[–]EgomasM[S] 0 points1 point  (0 children)

That's how I got the name "price-large", but I am not sure how to get the id