def spider_user_info(): tokens = get_tokens() for token in tokens: twitter = token.get('twitter_url') if not twitter or not twitter.strip(): continue token_name = token['token_name'] token_id = token['token_id'] username = twitter.split('/')[-1] get_user_info.delay(token_name, username, token_id)
def statistic_tokens_address(): collection = Mongo().token tokens = get_tokens() for token in tokens: token_name = token['ticker'].lower() code, address, increase = statistic_token_address(token_name) if not code: address = 0 increase = 0 db_result = collection.find_one({'token_name': token_name}) if db_result: db_result.update({ 'address': address, 'address_increase': increase }) collection.save(db_result) else: collection.insert({ 'token_name': token_name, 'address': address, 'address_increase': increase })
def send_token_info(): collection = Mongo().token tokens = get_tokens() for token in tokens: token_name = token['ticker'].lower() db_result = collection.find_one({ 'token_name': token_name }) if not db_result: continue data = { 'token_id': token['token_id'], 'transaction': db_result.get('transaction', 0), 'holders': db_result.get('address', 0), 'holders_increase': db_result.get('address_increase', 0) } try: result = requests.post(conf['sync']['host'] + conf['sync']['token_info'], data) except: pass # TODO test_environment send_test_token_info()
def sync_token_github(): tokens = get_tokens() for token in tokens: send_single_token_github(token['token_id'], token['ticker'].lower()) sync_test_token_github()
def start_spider(): tokens = get_tokens() for token in tokens: get_google_trend(token['name'], token['token_id']) time.sleep(5)