|
@@ -10,11 +10,52 @@ from common.mq import MQ
|
|
|
from common.public import download_rule, get_config_from_mysql
|
|
|
|
|
|
proxies = {"http": None, "https": None}
|
|
|
-
|
|
|
+headers = {
|
|
|
+ 'Host': 'mini.vvuiiu.cn',
|
|
|
+ 'accept': '*/*',
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ 'accept-language': 'zh-cn',
|
|
|
+ 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E217 MicroMessenger/6.8.0(0x16080000) NetType/WIFI Language/en Branch/Br_trunk MiniProgramEnv/Mac',
|
|
|
+ 'referer': 'https://servicewechat.com/wxa903dc775e85eb5b/11/page-frame.html'
|
|
|
+ }
|
|
|
|
|
|
class ZfshRecommend:
|
|
|
platform = ("祝福生活视频")
|
|
|
|
|
|
+ @classmethod
|
|
|
+ def get_video_url(cls, id, uuid1, log_type, crawler, env):
|
|
|
+ try:
|
|
|
+ url = "https://mini.vvuiiu.cn/article/detail"
|
|
|
+
|
|
|
+ payload = json.dumps({
|
|
|
+ "id": id,
|
|
|
+ "uuid": uuid1,
|
|
|
+ "platform": 35,
|
|
|
+ "appid": "wxa903dc775e85eb5b"
|
|
|
+ })
|
|
|
+ r = requests.post(url=url, headers=headers, data=payload, proxies=proxies, verify=False)
|
|
|
+ if "data" not in r.text or r.status_code != 200:
|
|
|
+ Common.logger(log_type, crawler).warning(f"get_videoList:{r.text}\n")
|
|
|
+ Common.logging(log_type, crawler, env, f"get_videoList:{r.text}\n")
|
|
|
+ return
|
|
|
+ elif "data" not in r.json():
|
|
|
+ Common.logger(log_type, crawler).info(f"get_videoList:{r.json()}\n")
|
|
|
+ Common.logging(log_type, crawler, env, f"get_videoList:{r.json()}\n")
|
|
|
+ return
|
|
|
+ elif len(r.json()["data"]) == 0:
|
|
|
+ Common.logger(log_type, crawler).warning(f"get_videoList:{r.json()['data']['list']}\n")
|
|
|
+ Common.logging(log_type, crawler, env, f"get_videoList:{r.json()['data']['list']}\n")
|
|
|
+ return
|
|
|
+ else:
|
|
|
+ # 获取视频url
|
|
|
+ video_url = r.json()["data"].get("video_url")
|
|
|
+ return video_url
|
|
|
+ except Exception as e:
|
|
|
+ Common.logger(log_type, crawler).error(f" 获取视频链接异常:{e}\n")
|
|
|
+ Common.logging(log_type, crawler, env, f"获取视频链接异常:{e}\n")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@classmethod
|
|
|
def repeat_video(cls, log_type, crawler, video_id, env):
|
|
|
sql = f""" select * from crawler_video where platform in ("{crawler}","{cls.platform}") and create_time>='2023-06-26' and out_video_id="{video_id}"; """
|
|
@@ -25,7 +66,7 @@ class ZfshRecommend:
|
|
|
def get_videoList(cls, log_type, crawler, our_uid, rule_dict, env):
|
|
|
mq = MQ(topic_name="topic_crawler_etl_" + env)
|
|
|
uuid1 = str(uuid.uuid1())
|
|
|
- for page in range(1, 100):
|
|
|
+ for page in range(1, 6):
|
|
|
try:
|
|
|
Common.logger(log_type, crawler).info(f"正在抓取第{page}页")
|
|
|
Common.logging(log_type, crawler, env, f"正在抓取第{page}页")
|
|
@@ -40,14 +81,7 @@ class ZfshRecommend:
|
|
|
"platform": 35,
|
|
|
"appid": "wxa903dc775e85eb5b"
|
|
|
})
|
|
|
- headers = {
|
|
|
- 'Host': 'mini.vvuiiu.cn',
|
|
|
- 'accept': '*/*',
|
|
|
- 'content-type': 'application/json',
|
|
|
- 'accept-language': 'zh-cn',
|
|
|
- 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E217 MicroMessenger/6.8.0(0x16080000) NetType/WIFI Language/en Branch/Br_trunk MiniProgramEnv/Mac',
|
|
|
- 'referer': 'https://servicewechat.com/wxa903dc775e85eb5b/11/page-frame.html'
|
|
|
- }
|
|
|
+
|
|
|
r = requests.post(url=url, headers=headers, data=payload, proxies=proxies, verify=False)
|
|
|
|
|
|
if "data" not in r.text or r.status_code != 200:
|
|
@@ -80,6 +114,9 @@ class ZfshRecommend:
|
|
|
.replace("'", "").replace("#", "").replace("Merge", "")
|
|
|
publish_time_stamp = int(feeds[i].get("article_id", 0))
|
|
|
publish_time_str = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(publish_time_stamp))
|
|
|
+ id = feeds[i]["id"]
|
|
|
+ # 获取视频链接
|
|
|
+ video_url = cls.get_video_url(id, uuid1, log_type, crawler, env)
|
|
|
video_dict = {
|
|
|
"video_title": video_title,
|
|
|
"video_id": feeds[i]["id"], # 视频id
|
|
@@ -88,7 +125,7 @@ class ZfshRecommend:
|
|
|
"is_video": int(feeds[i].get("is_video", 0)), # 类型
|
|
|
"category_id": int(feeds[i].get("category_id", 0)), # 视频来源(精彩推荐)
|
|
|
"image_path": feeds[i].get("image_path", ""), # 视频封面
|
|
|
- "video_url": feeds[i].get("video_url", ""), # 视频链接
|
|
|
+ "video_url": video_url, # 视频链接
|
|
|
"click": int(feeds[i].get("click", 0)), # 点击数
|
|
|
"video_width": int(feeds[i].get("vw", 0)),
|
|
|
"video_height": int(feeds[i].get("vh", 0)),
|