def crawler_otc_online(): r = do_crawler("https://otcbtc.com/") html_doc = r soup = BeautifulSoup(html_doc, 'html.parser') symbol = soup.find_all(current_online)[0].text.split("\n")[1].split( u":")[1].replace(",", "") return int(symbol)
def crawler_otc(url): r = do_crawler(url) html_doc = r soup = BeautifulSoup(html_doc, 'html.parser') symbol = soup.find_all(price_content) lowest = symbol[0].text return int(100 * float(lowest.split("\n")[2].strip()))
def crawler_money_flow(url, usd_rate): r = do_crawler(url) data = cjson.decode(r)['data'] return { '1w': int( ((data['inflow_1w'] - data['outflow_1w']) * usd_rate) / 10000), '1d': int( ((data['inflow_1d'] - data['outflow_1d']) * usd_rate) / 10000), '1h': int((data['inflow_1h'] - data['outflow_1h']) * usd_rate / 10000), '30m': int( (data['inflow_30m'] - data['outflow_30m']) * usd_rate / 10000), }
def crawler_eos_by_all(): now = int(round(time.time() * 1000)) start = 1356969600000 r = do_crawler("https://graphs2.coinmarketcap.com/currencies/eos/%s/%s/" % (start, now)) data = cjson.decode(r)['price_usd'] for d in data: value = time.localtime(d[0] / 1000) format_str = '%Y-%m-%d %H:%M:%S' dt = time.strftime(format_str, value) d[0] = dt return jsonify({'code': 200, 'data': data})
from crawler.crawler_api import do_crawler from opdb import database # do crawler print do_crawler("http://www.baidu.com") # db db = database.Connection(host="127.0.0.1", database='', user='', password='******') # query one db.get() # query many db.query() # update and return count db.execute_rowcount()
def crawler_current(url): r = do_crawler(url) data = cjson.decode(r)['data'] return Decimal(float(data['detail']['price']) * float(data['rate']) * 100).quantize(Decimal('0')), float(data['rate'])