From 92c8b3a6f758961288baaea72d9ceeb98961e1f0 Mon Sep 17 00:00:00 2001 From: alpcentaur Date: Fri, 8 Dec 2023 14:33:01 +0100 Subject: [PATCH] spider is posting to rooms based on tags now --- fdb_spider_interface.py | 25 +++++++++++++++++++++++-- new_message_file.txt | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/fdb_spider_interface.py b/fdb_spider_interface.py index 5db4917..04bdf01 100644 --- a/fdb_spider_interface.py +++ b/fdb_spider_interface.py @@ -99,11 +99,12 @@ if __name__ == '__main__': for room in room_list: print(room[0]) room_fdbs = room[2] + room_tags = room[3] #subprocess.run(["python", spider_directory + 'main.py', fdbs]) for room_fdb in eval(room_fdbs): #print('room_fdb',room_fdb, 'fdb_list',fdb_list) - if room_fdb in fdb_list: + if room_fdb in fdb_list and room_fdb not in [key for key in data]: try: iteration_var_list = config.get(room_fdb).get("entry-list").get("iteration-var-list") except Exception as e: @@ -119,11 +120,31 @@ if __name__ == '__main__': data[room_fdb] = iterdict + for i in eval(iteration_var_list): + + for key in data[room_fdb][i]: + contains_tag = False + for tag in eval(room_tags): + if tag in (data[room_fdb][i][key]["name"].split(' ') or data[room_fdb][i][key]["info"].split(' ') or data[room_fdb][i][key]["text"].split(' ')): + contains_tag = True + if contains_tag == True: + + try: + url = data[room_fdb][i][key]["domain"] + except: + url = data[room_fdb][i][key]["link"] + + + + entry_message = '[' + url + ']' + data[room_fdb][i][key]["name"] + '\n' + data[room_fdb][i][key]["info"] + + api.send_message(entry_message, room[0]) + - print('data',data['giz'][2],'data') + #print('data',data['giz'][2],'data') already_updated = True diff --git a/new_message_file.txt b/new_message_file.txt index 4a483b9..0b6c761 100644 --- a/new_message_file.txt +++ b/new_message_file.txt @@ -1 +1 @@ -printfdbs§%§%GGDZAhgELP2HDS5eM \ No newline at end of file +printfdbs§%§%cm9qFkkcbXdKuzXmC \ No newline at end of file