|
@@ -1,8 +1,13 @@
|
|
|
|
+"""
|
|
|
|
+监测已发布文章
|
|
|
|
+"""
|
|
|
|
+
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
from argparse import ArgumentParser
|
|
from argparse import ArgumentParser
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
|
from tqdm import tqdm
|
|
from tqdm import tqdm
|
|
|
|
+from applications import bot
|
|
from applications.db import DatabaseConnector
|
|
from applications.db import DatabaseConnector
|
|
from applications.const import updatePublishedMsgTaskConst
|
|
from applications.const import updatePublishedMsgTaskConst
|
|
from applications import WeixinSpider
|
|
from applications import WeixinSpider
|
|
@@ -28,10 +33,22 @@ def monitor_article(article):
|
|
VALUES
|
|
VALUES
|
|
(%s, %s, %s, %s, %s, %s);
|
|
(%s, %s, %s, %s, %s, %s);
|
|
"""
|
|
"""
|
|
- long_articles_db_client.save(
|
|
|
|
|
|
+ affected_rows = long_articles_db_client.save(
|
|
query=insert_sql,
|
|
query=insert_sql,
|
|
params=(gh_id, account_name, title, wx_sn, publish_date, error_detail),
|
|
params=(gh_id, account_name, title, wx_sn, publish_date, error_detail),
|
|
)
|
|
)
|
|
|
|
+ if affected_rows:
|
|
|
|
+ bot(
|
|
|
|
+ title="文章违规告警",
|
|
|
|
+ detail={
|
|
|
|
+ "account_name": account_name,
|
|
|
|
+ "gh_id": gh_id,
|
|
|
|
+ "title": title,
|
|
|
|
+ "wx_sn": wx_sn,
|
|
|
|
+ "publish_date": publish_date,
|
|
|
|
+ "error_detail": error_detail,
|
|
|
|
+ }
|
|
|
|
+ )
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(e)
|
|
print(e)
|
|
|
|
|
|
@@ -45,7 +62,7 @@ def get_article_list(run_date):
|
|
run_date = datetime.today().strftime("%Y-%m-%d")
|
|
run_date = datetime.today().strftime("%Y-%m-%d")
|
|
|
|
|
|
monitor_start_timestamp = (
|
|
monitor_start_timestamp = (
|
|
- int(datetime.strptime(run_date, "%Y-%m-%d").timestamp()) - const.MONITOR_PERIOD
|
|
|
|
|
|
+ int(datetime.strptime(run_date, "%Y-%m-%d").timestamp()) - const.MONITOR_PERIOD
|
|
)
|
|
)
|
|
select_sql = f"""
|
|
select_sql = f"""
|
|
SELECT ghId, accountName, title, ContentUrl, wx_sn, from_unixtime(publish_timestamp) AS publish_timestamp
|
|
SELECT ghId, accountName, title, ContentUrl, wx_sn, from_unixtime(publish_timestamp) AS publish_timestamp
|