zhangyong 8 tháng trước cách đây
mục cha
commit
4d544ab1ba
2 tập tin đã thay đổi với 15 bổ sung4 xóa
  1. 10 1
      common/sql_help.py
  2. 5 3
      data_channel/sph_crawling_data.py

+ 10 - 1
common/sql_help.py

@@ -124,6 +124,15 @@ class sqlCollect():
         data = MysqlHelper.get_values(sql, (user, channel))
         return data[0]
 
+    """获取视频号历史数据"""
+    @classmethod
+    def sph_data_info_list(cls, user, channel):
+        sql = """SELECT video_id, video_title, share_count, like_count, oss_url, oss_cover  FROM sph_data_info WHERE nick_name = %s and channel = %s """
+        data = MysqlHelper.get_values(sql, (user, channel))
+        if data:
+            return data
+        return None
+
     """查询是否有视频号数据"""
     @classmethod
     def sph_channel_user_list(cls):
@@ -143,7 +152,7 @@ class sqlCollect():
         视频号账号状态改为1 代表已经抓取过
         """
         sql = f"""UPDATE sph_channel_user set status = 1 where user_id = '{user}'"""
-        res = AigcMysqlHelper.update_values(
+        res = MysqlHelper.update_values(
             sql=sql
         )
         return res

+ 5 - 3
data_channel/sph_crawling_data.py

@@ -37,6 +37,8 @@ class SphHistory:
 
                     response = requests.request("POST", url, headers=headers, data=payload)
                     time.sleep(random.randint(1, 5))
+                    if response.text == "" or response.text == None:
+                        break
                     res_json = response.json()
                     try:
                         if len(res_json["DownloadAddress"]) == 0 or res_json["DownloadAddress"] == "" or res_json["DownloadAddress"] == None:
@@ -130,6 +132,6 @@ class SphHistory:
 
 
 if __name__ == '__main__':
-    # SphHistory.sph_data_info()
-    count = sqlCollect.sph_data_info_count("郑蓝旗", "视频号")
-    print(count)
+    SphHistory.sph_data_info()
+    # count = sqlCollect.sph_data_info_count("郑蓝旗", "视频号")
+    # print(count)