Last active
December 31, 2015 06:39
-
-
Save xorrbit/7949371 to your computer and use it in GitHub Desktop.
Scrapes doge/btd and cad/doge and tells you cad per 100k doge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib2 | |
import re | |
cadpat = re.compile('Daily.*?<td> ([0-9.]+) \(CAD\)', re.DOTALL) | |
dogepat = re.compile('DOGE/BTC<div.*?>\(last: ([0-9.]+)\)</') | |
def get_html(url): | |
_, html = httplib2.Http(disable_ssl_certificate_validation=True).request(url) | |
return html | |
def get_doge_per_btc(): | |
html = get_html("https://coinedup.com/OrderBook?market=DOGE&base=BTC") | |
return dogepat.findall(html)[0] | |
def get_cad_per_btc(): | |
html = get_html("https://www.cavirtex.com/home") | |
return cadpat.findall(html)[0] | |
def main(): | |
doges = get_doge_per_btc() | |
cads = get_cad_per_btc() | |
print " DOGE per BTC last: " + doges | |
print " $CAD per BTC last: " + cads | |
cad_per_100kdoge = float(doges) * float(cads) * 100000 | |
print "$CAD per 100k DOGE: " + str(int(cad_per_100kdoge)) | |
cad_per_4mildoge = cad_per_100kdoge * 40 | |
print "$CAD per 4mil DOGE: " + str(int(cad_per_4mildoge)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment