def _post(self, func, endpoint, payload) : err_msg = '' for _ in range(self.retry_count) : try : post_raw(AUTOCOMPLETE_ADDRESS + "/" + endpoint, payload.encode('utf-8')) return except Exception as e : err_msg = str(e) print('FAILED: %s message=%s' % (func, err_msg), file = sys.stderr)
def cut_for_index(txt): if isinstance(txt, list): return list( set(itertools.chain.from_iterable([cut_for_index(i) for i in txt]))) return loads(post_raw(TEXTSEG_ADDRESS + 'i/', txt.encode('utf-8')).text)['Words']
def _postPlaylistTask(url, pid, use_autotag, user, extend=False): post_obj = { 'use_autotag': use_autotag, 'url': url, 'pid': pid, 'user': user, 'event_id': getEventID(), 'extend': extend } post_obj_json_str = dumps(post_obj) ret_obj = loads( post_raw(SCRAPER_ADDRESS + "/playlist", post_obj_json_str.encode('utf-8')).text) return ret_obj['task_id']
def postTask(json_str): ret_obj = loads( post_raw(SCRAPER_ADDRESS + "/video", json_str.encode('utf-8')).text) return ret_obj['task_id']
def find_touhou_words(txt): resp = post_raw(TEXTSEG_ADDRESS + 't/', txt.encode('utf-8')) txt = resp.content.decode('utf-8') words = loads(txt) return words
def cut_for_search(txt): resp = post_raw(TEXTSEG_ADDRESS + 's/', txt.encode('utf-8')) txt = resp.content.decode('utf-8') words = loads(txt)['Words'] return words