|
@@ -81,8 +81,63 @@ def check_data_count():
|
|
|
conn.close()
|
|
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
-if __name__ == '__main__':
|
|
|
|
|
- with sync_playwright() as playwright:
|
|
|
|
|
- run(playwright)
|
|
|
|
|
|
|
+def read_ids():
|
|
|
|
|
+ ids = []
|
|
|
|
|
+ # 数据库连接参数
|
|
|
|
|
+ db_params = {
|
|
|
|
|
+ 'dbname': 'freshrss',
|
|
|
|
|
+ 'user': 'freshrss',
|
|
|
|
|
+ 'password': 'freshrss',
|
|
|
|
|
+ 'host': 'erhe.top',
|
|
|
|
|
+ 'port': '20788'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ # SQL 查询语句
|
|
|
|
|
+ query = 'SELECT id, url FROM freshrss_toor_feed order by id ASC;'
|
|
|
|
|
+
|
|
|
|
|
+ try:
|
|
|
|
|
+ # 建立数据库连接
|
|
|
|
|
+ conn = psycopg2.connect(**db_params)
|
|
|
|
|
+
|
|
|
|
|
+ # 创建 cursor 对象
|
|
|
|
|
+ cur = conn.cursor()
|
|
|
|
|
+
|
|
|
|
|
+ # 执行 SQL 查询
|
|
|
|
|
+ cur.execute(query)
|
|
|
|
|
+
|
|
|
|
|
+ # 获取查询结果
|
|
|
|
|
+ records = cur.fetchall()
|
|
|
|
|
+
|
|
|
|
|
+ for record in records:
|
|
|
|
|
+ id, url = record
|
|
|
|
|
+ print(id, url)
|
|
|
|
|
+ ids.append(id)
|
|
|
|
|
+
|
|
|
|
|
+ except psycopg2.Error as e:
|
|
|
|
|
+ print(f"Database error: {e}")
|
|
|
|
|
+ conn.rollback()
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ print(f"An error occurred: {e}")
|
|
|
|
|
+ finally:
|
|
|
|
|
+ # 关闭 cursor 和连接
|
|
|
|
|
+ if 'cur' in locals():
|
|
|
|
|
+ cur.close()
|
|
|
|
|
+ if 'conn' in locals():
|
|
|
|
|
+ conn.close()
|
|
|
|
|
+
|
|
|
|
|
+ if ids:
|
|
|
|
|
+ return ids
|
|
|
|
|
+ else:
|
|
|
|
|
+ return None
|
|
|
|
|
|
|
|
- check_data_count()
|
|
|
|
|
|
|
+
|
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
|
+ ids = read_ids()
|
|
|
|
|
+
|
|
|
|
|
+ if not ids:
|
|
|
|
|
+ print('未获取到订阅源id, 程序退出')
|
|
|
|
|
+ exit(0)
|
|
|
|
|
+ # with sync_playwright() as playwright:
|
|
|
|
|
+ # run(playwright)
|
|
|
|
|
+ #
|
|
|
|
|
+ # check_data_count()
|