|
@@ -0,0 +1,130 @@
|
|
|
+import random
|
|
|
+import time
|
|
|
+
|
|
|
+import requests
|
|
|
+import json
|
|
|
+import re
|
|
|
+
|
|
|
+from common import Material, Feishu, Common
|
|
|
+from common.sql_help import sqlCollect
|
|
|
+
|
|
|
+class SphNrxs:
|
|
|
+
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def get_sph_data(cls, user):
|
|
|
+ url = "http://61.48.133.26:30001/FinderGetUpMasterNextPage"
|
|
|
+ count = 1
|
|
|
+ headers = {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+ payload = json.dumps({
|
|
|
+ "username": user,
|
|
|
+ "last_buffer": ""
|
|
|
+ })
|
|
|
+
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
+ time.sleep(random.randint(1, 5))
|
|
|
+ Common.logger("sph_nrxs").info(f"{user}获取第{count}页视频")
|
|
|
+ count += 1
|
|
|
+ if response.text == "" or response.text == None:
|
|
|
+ return
|
|
|
+ res_json = response.json()
|
|
|
+ try:
|
|
|
+ if len(res_json["DownloadAddress"]) == 0 or res_json["DownloadAddress"] == "" or res_json[
|
|
|
+ "DownloadAddress"] == None:
|
|
|
+ return
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ if "objectId" not in response.text or response.status_code != 200:
|
|
|
+ return
|
|
|
+ if len(res_json["UpMasterHomePage"]) == 0:
|
|
|
+ return
|
|
|
+ if not res_json["UpMasterHomePage"]:
|
|
|
+ return
|
|
|
+ try:
|
|
|
+ for obj in res_json["UpMasterHomePage"]:
|
|
|
+ Common.logger("sph_crawling").info(f"{user}扫描到一条数据")
|
|
|
+ objectId = obj['objectId']
|
|
|
+ object_id = sqlCollect.sph_data_info_v_id(objectId, "视频号")
|
|
|
+ if object_id:
|
|
|
+ continue
|
|
|
+ objectNonceId = obj['objectNonceId']
|
|
|
+ url1 = "http://61.48.133.26:30001/GetFinderDownloadAddress"
|
|
|
+ payload = json.dumps({
|
|
|
+ "objectId": objectId,
|
|
|
+ "objectNonceId": objectNonceId
|
|
|
+ })
|
|
|
+ headers = {
|
|
|
+ 'Content-Type': 'text/plain'
|
|
|
+ }
|
|
|
+ response = requests.request("POST", url1, headers=headers, data=payload)
|
|
|
+ time.sleep(random.randint(0, 1))
|
|
|
+ video_obj = response.json()
|
|
|
+ video_url = video_obj.get('DownloadAddress')
|
|
|
+ duration = video_obj.get('play_len')
|
|
|
+ cover = video_obj.get('thumb_url')
|
|
|
+ if len(video_url) == 0:
|
|
|
+ continue
|
|
|
+
|
|
|
+ share_cnt = int(obj['forward_count']) # 分享
|
|
|
+ like_cnt = int(obj['like_count']) # 点赞
|
|
|
+ user_name = obj['username'] # 用户名标示
|
|
|
+ nick_name = obj['nickname'] # 用户名
|
|
|
+ comment_count = obj['comment_count'] # 评论数
|
|
|
+ fav_count = obj['fav_count'] # 大拇指点赞数
|
|
|
+ Common.logger("sph_nrxs").info(f"{nick_name}符合规则")
|
|
|
+ except Exception as e:
|
|
|
+ Common.logger("sph_nrxs").info(f"{user}异常,异常信息{e}")
|
|
|
+ return
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def get_nrxs_list(cls):
|
|
|
+ list = []
|
|
|
+ cookie = Material.get_cookie_data("KsoMsyP2ghleM9tzBfmcEEXBnXg", "U1gySe", "视频号加热")
|
|
|
+ url = "http://8.217.190.241:8888/crawler/wei_xin/shi_pin_hao/jia_re"
|
|
|
+
|
|
|
+ payload = json.dumps({
|
|
|
+ "account_name": "央视新闻",
|
|
|
+ "category": "推荐",
|
|
|
+ "cookie": cookie
|
|
|
+ })
|
|
|
+ headers = {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+ try:
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
+ response = response.json()
|
|
|
+ code = response['code']
|
|
|
+ if code == 0:
|
|
|
+ data_list = response['data']['data']
|
|
|
+ if data_list:
|
|
|
+ for data in data_list:
|
|
|
+ nick_name = data['nickName'] # 用户名
|
|
|
+ user_name = data['username'] # 用户v2
|
|
|
+ data_dict = {"nick_name": nick_name, "user_name": user_name}
|
|
|
+ list.append(data_dict)
|
|
|
+ else:
|
|
|
+ Feishu.bot("xinxin", '视频号加热提醒', f'cookie 失效了,请即使更换', 'xinxin')
|
|
|
+ return None
|
|
|
+ except Exception as e:
|
|
|
+ Feishu.bot("xinxin", '视频号加热提醒', f'cookie 失效了,请即使更换', 'xinxin')
|
|
|
+ Common.logger("feishu").error(f"视频号加热bot异常:{e}\n")
|
|
|
+ return None
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def sph_nrxs_data(cls):
|
|
|
+ user = sqlCollect.get_machine_making_reflux("视频号", "单点视频")
|
|
|
+ if user == None:
|
|
|
+ return
|
|
|
+ user = [item[0] for item in user]
|
|
|
+ for uid in user:
|
|
|
+ if re.match(r'^[A-Za-z0-9]+$', uid):
|
|
|
+ # 匹配成功,进行下一次循环
|
|
|
+ continue
|
|
|
+ print(uid)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ SphNrxs.get_nrxs_list()
|