Sha256: 2951dea0a744eddc23e3aecb9c80ca99a1f82a085710e664490d2ad9f5d4f526
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
class CryptoPrice::Scraper def self.scrape_coinmarketcap #binding.pry #doc = Nokogiri::HTML(open("https://coinmarketcap.com")) #doc.css("tbody.span").text.split("$").select{ |k| k.length > 0 } doc = Nokogiri::HTML(open("https://coinstats.app/?pagesize=50&page=1")) doc.css("td.data-cell.mobile-last").text.split("$").select{ |k| k.length > 0 } end def self.scrape_coinlib doc = Nokogiri::HTML(open("https://coinlib.io/coins")) prices = self.scrape_coinmarketcap names = doc.css("div.tbl-currency").text.split("\n").select{ |k| !k.include?("[") && k.length > 0 } symbols = doc.css("span.tbl-coin-abbrev").text.gsub("]", "").split("[").select{ |k| k.length > 0 } changes = doc.css("span.tbl-price.pr-change").text.split("%").select{ |k| k.length > 0 } marketcaps = doc.css("span.mob-info-value").text.split("$").select{ |k| k.length > 0 } #binding.pry index = 0 while index < names.length && index < symbols.length symbol = symbols[index] name = names[index] price = prices[index] change = changes[index] marketcap = marketcaps[index] CryptoPrice::Coin.new(symbol, name, price,change, marketcap) index += 1 end CryptoPrice::Coin.all end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
crypto_price-0.1.3 | lib/crypto_price/scraper.rb |