|
@@ -0,0 +1,169 @@
|
|
|
+
|
|
|
+import os
|
|
|
+import random
|
|
|
+import subprocess
|
|
|
+import sys
|
|
|
+import time
|
|
|
+import uuid
|
|
|
+import requests
|
|
|
+from datetime import datetime, timedelta
|
|
|
+from appium import webdriver
|
|
|
+from appium.webdriver.extensions.android.nativekey import AndroidKey
|
|
|
+from appium.webdriver.common.touch_action import TouchAction
|
|
|
+from bs4 import BeautifulSoup
|
|
|
+from selenium.common.exceptions import NoSuchElementException
|
|
|
+from selenium.webdriver.common.by import By
|
|
|
+
|
|
|
+from application.common.redis.xng_redis import xng_get_video_data
|
|
|
+
|
|
|
+
|
|
|
+class XiaoNianGaoZH(object):
|
|
|
+
|
|
|
+ def save_pq_uid(self, content):
|
|
|
+ current_time = datetime.now()
|
|
|
+ time_after_10_minutes = current_time + timedelta(minutes=5)
|
|
|
+ # 获取时间戳
|
|
|
+ timestamp_seconds = time_after_10_minutes.timestamp()
|
|
|
+ timestamp_milliseconds = int(timestamp_seconds * 1000)
|
|
|
+
|
|
|
+ url = "https://admin.piaoquantv.com/manager/crawler/v3/task/save?muid=999"
|
|
|
+ payload = {
|
|
|
+ "taskName": "小年糕账号",
|
|
|
+ "source": "xiaoniangao",
|
|
|
+ "mode": "author",
|
|
|
+ "modeValue": "0",
|
|
|
+ "modeBoard": "0",
|
|
|
+ "spiderName": "run_xng_author",
|
|
|
+ "startTime": timestamp_milliseconds,
|
|
|
+ "interval": 4800,
|
|
|
+ "uid": str(content),
|
|
|
+ "machine": "aliyun",
|
|
|
+ "rule": [{"period": {"min": 15, "max": 3}},
|
|
|
+ {"duration": {"min": 50, "max": 0}},
|
|
|
+ {"share_cnt": {"min": 2, "max": 0}},
|
|
|
+ {"videos_cnt": {"min": 300, "max": 0}}],
|
|
|
+ "id": 21
|
|
|
+ }
|
|
|
+ headers = {
|
|
|
+ 'accept': 'application/json',
|
|
|
+ 'content-type': 'application/json;',
|
|
|
+ 'cookie': 'SESSION=YjM4YmE5NDgtMjJmNi00NjA1LTgyNDUtYTNlZGVlOGNmODMy',
|
|
|
+ 'origin': 'https://admin.piaoquantv.com',
|
|
|
+ 'pragma': 'no-cache',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
|
|
|
+ }
|
|
|
+
|
|
|
+ requests.request("POST", url, headers=headers, json=payload)
|
|
|
+
|
|
|
+
|
|
|
+ def get_tag_id(self, date_int):
|
|
|
+ for i in range(3):
|
|
|
+ url = f"https://admin.piaoquantv.com/manager/user/up/searchUserTypeTag?keyword={date_int}&muid=7?muid=999"
|
|
|
+
|
|
|
+ payload = {}
|
|
|
+ headers = {
|
|
|
+ 'content-length': '0',
|
|
|
+ 'cookie': 'SESSION=YjM4YmE5NDgtMjJmNi00NjA1LTgyNDUtYTNlZGVlOGNmODMy',
|
|
|
+ 'origin': 'https://admin.piaoquantv.com',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
|
|
+ 'sec-ch-ua-mobile': '?0',
|
|
|
+ 'sec-ch-ua-platform': '"macOS"'
|
|
|
+ }
|
|
|
+
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
+ response = response.json()
|
|
|
+ content = response["content"]
|
|
|
+ if content:
|
|
|
+ tagId = content[0]['tagId']
|
|
|
+ return tagId
|
|
|
+ else:
|
|
|
+ url = f"https://admin.piaoquantv.com/manager/user/up/createUserTypeTag?tagName={date_int}&muid=7?muid=999"
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
+ response = response.json()
|
|
|
+ content = response["content"]
|
|
|
+ if content:
|
|
|
+ tagId = content['tagId']
|
|
|
+ return tagId
|
|
|
+
|
|
|
+ def insert_number(self, mid, tag_id):
|
|
|
+ for i in range(3):
|
|
|
+ url = "https://admin.piaoquantv.com/manager/crawler/v3/user/save?muid=999"
|
|
|
+ payload = {
|
|
|
+ "source": "xiaoniangao",
|
|
|
+ "mode": "author",
|
|
|
+ "modeValue": "",
|
|
|
+ "modeBoard": "",
|
|
|
+ "recomStatus": -6,
|
|
|
+ "appRecomStatus": -6,
|
|
|
+ "autoAuditStatus": 0,
|
|
|
+ "tag": f"459,454,106,8240,{int(tag_id)}",
|
|
|
+ "contentCategory": 0,
|
|
|
+ "link": str(mid)
|
|
|
+ }
|
|
|
+
|
|
|
+ headers = {
|
|
|
+ 'content-length': '0',
|
|
|
+ 'cookie': 'SESSION=YjM4YmE5NDgtMjJmNi00NjA1LTgyNDUtYTNlZGVlOGNmODMy',
|
|
|
+ 'origin': 'https://admin.piaoquantv.com',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
|
|
|
+ 'sec-ch-ua-mobile': '?0',
|
|
|
+ 'sec-ch-ua-platform': '"macOS"'
|
|
|
+ }
|
|
|
+
|
|
|
+ response = requests.request("POST", url, headers=headers, json=payload)
|
|
|
+ response = response.json()
|
|
|
+ code = response["code"]
|
|
|
+ if code == 0:
|
|
|
+ print("添加账号成功")
|
|
|
+ time.sleep(1)
|
|
|
+ url = "https://admin.piaoquantv.com/manager/crawler/v3/user/list?muid=999"
|
|
|
+ payload = {
|
|
|
+ "pageNum": 1,
|
|
|
+ "pageSize": 20
|
|
|
+ }
|
|
|
+ response = requests.request("POST", url, headers=headers, json=payload)
|
|
|
+ response = response.json()
|
|
|
+ list = response["content"]['list']
|
|
|
+ link = list[0]["link"]
|
|
|
+ if link == str(mid):
|
|
|
+ print("获取站内账号ID成功")
|
|
|
+ return list[0]["uid"]
|
|
|
+
|
|
|
+ def get_video_info_2(self):
|
|
|
+ mid_list = []
|
|
|
+ while True:
|
|
|
+ mid = xng_get_video_data()
|
|
|
+ if mid:
|
|
|
+ mid = mid["mid"]
|
|
|
+ mid_list.append(mid)
|
|
|
+ else:
|
|
|
+ break
|
|
|
+ if mid_list:
|
|
|
+ current_time = datetime.now()
|
|
|
+ formatted_time = current_time.strftime("%Y%m%d")
|
|
|
+ date_int = int(formatted_time)
|
|
|
+ tag_id = self.get_tag_id(date_int)
|
|
|
+ mid_list = list(set(mid_list))
|
|
|
+ for m_id in mid_list:
|
|
|
+ time.sleep(2)
|
|
|
+ print(tag_id)
|
|
|
+ # 新增账号
|
|
|
+ pq_uid = self.insert_number(m_id, tag_id)
|
|
|
+ if pq_uid:
|
|
|
+ file_path = '/root/automatic_crawler/spider/crawler_offline/xng_zh.txt'
|
|
|
+ with open(file_path, 'r') as file:
|
|
|
+ content = file.read()
|
|
|
+ if content and content[-1] != ',':
|
|
|
+ uid = ',' + str(uid)
|
|
|
+ with open(file_path, 'a') as file:
|
|
|
+ file.write(uid)
|
|
|
+ with open(file_path, 'r') as file:
|
|
|
+ content = file.read()
|
|
|
+ time.sleep(1)
|
|
|
+ self.save_pq_uid(content)
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ XiaoNianGaoZH.get_video_info_2()
|