12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import json
- from application.common.mysql import MysqlHelper
- def get_config_from_mysql(log_type, source, text):
- """
- :param log_type: mode
- :param source: platform
- :param text:
- :return:
- """
- select_sql = f"""select config from crawler_config where source="{source}" """
- MySQL = MysqlHelper(mode=log_type, platform=select_sql)
- configs = MySQL.select(select_sql)
- title_list = []
- filter_list = []
- emoji_list = []
- search_word_list = []
- for config in configs:
- config_dict = json.loads(config[0])
- for k, v in config_dict.items():
- if k == "title":
- title_list_config = v.split(",")
- for title in title_list_config:
- title_list.append(title)
- if k == "filter":
- filter_list_config = v.split(",")
- for filter_word in filter_list_config:
- filter_list.append(filter_word)
- if k == "emoji":
- emoji_list_config = v.split(",")
- for emoji in emoji_list_config:
- emoji_list.append(emoji)
- if k == "search_word":
- search_word_list_config = v.split(",")
- for search_word in search_word_list_config:
- search_word_list.append(search_word)
- if text == "title":
- return title_list
- elif text == "filter":
- return filter_list
- elif text == "emoji":
- return emoji_list
- elif text == "search_word":
- return search_word_list
|