def get_task_rule_property(base_url, token, task_id, action_name): """Get Task Parameters This returns the different parameters for a specific task, for example, the URL from ‘Go To The Web Page’ action, text value from ‘Enter Text’ action and text list/URL list from ‘Loop Item’ action. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform action_name {[type]} -- a unique combination name of an action and a parameter from a task, like 'navigateAction1.Url' or 'loopAction2.TextList' Returns: list -- value list of a given action parameter """ print('GetTaskRulePropertyByName: ' + action_name) url = 'api/task/GetTaskRulePropertyByName?taskId=' + task_id + '&name=' + action_name response = util.request_t_post(base_url, url, token) property_list = [] if 'error' in response: if response['error'] == 'success': property_list = response['data'] for pro in property_list: print(pro) else: print(response['error_Description']) else: print(response) return property_list
def get_task_rule_property(base_url, token, task_id, action_name): """Get Task Parameters This returns the different parameters for a specific task, for example, the URL from ‘Go To The Web Page’ action, text value from ‘Enter Text’ action and text list/URL list from ‘Loop Item’ action. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform action_name {[type]} -- a unique combination name of an action and a parameter from a task, like 'navigateAction1.Url' or 'loopAction2.TextList' Returns: list -- value list of a given action parameter """ print('GetTaskRulePropertyByName: ' + action_name) url = 'api/task/GetTaskRulePropertyByName?taskId=' + task_id + '&name=' + action_name response = util.request_t_post(base_url, url, token) property_list = [] if 'error' in response: if response['error'] == 'success': property_list = response['data'] for pro in property_list: print(pro) else: print(response['error_Description']) else: print(response) return property_list;
def update_task_rule_property(base_url, token, task_id, action_name, property_value): """Update Task Parameters Use this method to update task parameters (currently only available to updating URL in ‘Go To The Web Page’ action, text value in ‘Enter Text’ action, and text list/URL list in ‘Loop Item’ action). Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform action_name {[type]} -- a unique combination name of an action and a parameter from a task, like 'navigateAction1.Url' or 'loopAction2.TextList' property_value {[type]} -- value of the parameter to set Returns: string -- remind message(include error if exists) """ print('UpdateTaskRuleProperty: ' + action_name) url = 'api/task/updateTaskRule' content = { 'taskId': task_id, 'name': action_name, 'value': json.dumps(property_value) } response = util.request_t_post(base_url, url, token, content) print(response['error_Description']) return response
def get_tasks_status(base_url, token, task_id_List): """This returns status of multiple tasks. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string list} -- task id(s) of one or more task(s) from our platform Returns: list -- status list of given task(s) """ print('TaskStatus:') url = 'api/task/getTaskStatusByIdList' content = {"taskIdList": task_id_List} response = util.request_t_post(base_url, url, token, content) task_status_list = [] if 'error' in response: if response['error'] == 'success': task_status_list = response['data'] for ts in task_status_list: print('%s\t%s\t%s' % (ts['taskId'], ts['taskName'], ts['status'])) else: print(response['error_Description']) else: print(response) return task_status_list
def get_tasks_status(base_url, token, task_id_List): """This returns status of multiple tasks. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string list} -- task id(s) of one or more task(s) from our platform Returns: list -- status list of given task(s) """ print('TaskStatus:') url = 'api/task/getTaskStatusByIdList' content = { "taskIdList": task_id_List } response = util.request_t_post(base_url, url, token, content) task_status_list = [] if 'error' in response: if response['error'] == 'success': task_status_list = response['data'] for ts in task_status_list: print('%s\t%s\t%s'%(ts['taskId'], ts['taskName'], ts['status'])) else: print(response['error_Description']) else: print(response) return task_status_list
def remove_task_data(base_url, token, task_id): """Clear data of a task Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform Returns: string -- remind message(include error if exists) """ print('RemoveTaskData:') url = 'api/task/removeDataByTaskId?taskId=' + task_id response = util.request_t_post(base_url, url, token) print(response['error_Description']) return response
def stop_task(base_url, token, task_id): """Stop Running Task Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform Returns: string -- remind message(include error if exists) """ print('StopTask:') url = 'api/task/stopTask?taskId=' + task_id response = util.request_t_post(base_url, url, token) print(response['error_Description']) return response
def stop_task(base_url, token, task_id): """Stop Running Task Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform Returns: string -- remind message(include error if exists) """ print('StopTask:') url = 'api/task/stopTask?taskId=' + task_id response = util.request_t_post(base_url, url, token) print(response['error_Description']) return response;
def mark_data_as_exported(base_url, token, task_id): """Update Data Status This updates data status from ‘exporting’ to ‘exported’. Note: Please confirm data exported via the API ‘Export Task Data’ (api/notexportdata/gettop) have been retrieved successfully before using this method. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform Returns: string -- remind message(include error if exists) """ print('MarkDataExported:') url = 'api/notExportData/Update?taskId=' + task_id response = util.request_t_post(base_url, url, token) print(response['error_Description']) return response
def add_url_or_text_item(base_url, token, task_id, action_name, property_value): """Adding URL/Text to a Loop Use this method to add new URLs/text to an existing loop. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform action_name {[type]} -- a unique combination name of an action and a parameter from a task, like 'navigateAction1.Url' or 'loopAction2.TextList' property_value {[type]} -- value of the parameter to set Returns: string -- remind message(include error if exists) """ print('AddUrlOrTextToTask: ' + action_name) url = 'api/task/AddUrlOrTextToTask' content = { 'taskId': task_id, 'name': action_name, 'value': property_value } response = util.request_t_post(base_url, url, token, content) print(response['error_Description']) return response;
def add_url_or_text_item(base_url, token, task_id, action_name, property_value): """Adding URL/Text to a Loop Use this method to add new URLs/text to an existing loop. Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform action_name {[type]} -- a unique combination name of an action and a parameter from a task, like 'navigateAction1.Url' or 'loopAction2.TextList' property_value {[type]} -- value of the parameter to set Returns: string -- remind message(include error if exists) """ print('AddUrlOrTextToTask: ' + action_name) url = 'api/task/AddUrlOrTextToTask' content = {'taskId': task_id, 'name': action_name, 'value': property_value} response = util.request_t_post(base_url, url, token, content) print(response['error_Description']) return response
def update_task_rule_property(base_url, token, task_id, action_name, property_value): """Update Task Parameters Use this method to update task parameters (currently only available to updating URL in ‘Go To The Web Page’ action, text value in ‘Enter Text’ action, and text list/URL list in ‘Loop Item’ action). Arguments: base_url {string} -- base url of the api token {string} -- token string from a valid token entity task_id {string} -- task id of a task from our platform action_name {[type]} -- a unique combination name of an action and a parameter from a task, like 'navigateAction1.Url' or 'loopAction2.TextList' property_value {[type]} -- value of the parameter to set Returns: string -- remind message(include error if exists) """ print('UpdateTaskRuleProperty: ' + action_name) url = 'api/task/updateTaskRule' content = { 'taskId': task_id, 'name': action_name, 'value': property_value } response = util.request_t_post(base_url, url, token, content) print(response['error_Description']) return response;
current_collection.create_index( [("source", pymongo.ASCENDING), ("title", pymongo.ASCENDING)], unique=True) current_collection.insert_one( list_result[article]) except pymongo.errors.DuplicateKeyError: continue else: current_collection.update(list_result[article], list_result[article], upsert=True) new_offset = dataResult['data']['offset'] elif mode == 'delete_data': if len(sys.argv) < 3: print("Please sepecify your frequency!") os.exit(-1) daily_frequency = sys.argv[2] for item in config: if (daily_frequency != 'daily' or (daily_frequency == 'daily' and ('daily_delete' in item) and item["daily_delete"])): print("Deleting data from article: ", item["source"]) task_id = item["id"] url = 'api/task/RemoveDataByTaskId?taskId=' + task_id util.request_t_post(base_url, url, token_entity['access_token']) # End