|
@@ -88,20 +88,6 @@ class Recommend:
|
|
|
try:
|
|
|
driver.implicitly_wait(10)
|
|
|
for i in range(5):
|
|
|
- # # 关闭页面弹窗
|
|
|
- # try:
|
|
|
- # driver.find_element(By.XPATH, '//*[@text="我知道了"]').click()
|
|
|
- # driver.find_element(By.XPATH, '//*[@text="知道了"]').click()
|
|
|
- # Common.logger(log_type).info('已关闭未成年模式弹窗')
|
|
|
- # except NoSuchElementException:
|
|
|
- # pass
|
|
|
- #
|
|
|
- # try:
|
|
|
- # driver.find_element(By.ID, 'com.tencent.mm:id/dkf')
|
|
|
- # Common.logger(log_type).info('直播视频,向上滑动页面\n')
|
|
|
- # driver.swipe(500, 1500, 500, 500, 300)
|
|
|
- # except NoSuchElementException:
|
|
|
- # pass
|
|
|
|
|
|
# 视频标题
|
|
|
try:
|
|
@@ -109,7 +95,7 @@ class Recommend:
|
|
|
video_title = title_id.get_attribute('name').split('\n')[0].replace('#', '').strip()
|
|
|
except NoSuchElementException:
|
|
|
video_title = ''
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
|
|
|
# 点击播放器,获取视频时长
|
|
|
# Common.logger(log_type).info('暂停播放')
|
|
@@ -186,27 +172,23 @@ class Recommend:
|
|
|
|
|
|
# 判断无效视频
|
|
|
if video_title == '' or user_name == '':
|
|
|
- Common.logger(log_type).info('向上滑动页面')
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
- Common.logger(log_type).info('无效视频\n')
|
|
|
+ Common.logger(log_type).info('无效视频,滑动到下一个视频\n')
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
|
|
|
# 判断下载规则
|
|
|
elif cls.download_rule(duration, like_cnt, share_cnt, favorite_cnt, comment_cnt) is False:
|
|
|
- Common.logger(log_type).info('向上滑动页面')
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
- Common.logger(log_type).info('不满足抓取规则\n')
|
|
|
+ Common.logger(log_type).info('不满足抓取规则,滑动到下一个视频\n')
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
|
|
|
# 已下载表去重
|
|
|
elif str(video_title) in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'c77cf9') for x in y]:
|
|
|
- Common.logger(log_type).info('向上滑动页面')
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
- Common.logger(log_type).info('视频已下载\n')
|
|
|
+ Common.logger(log_type).info('视频已下载,滑动到下一个视频\n')
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
|
|
|
# feeds 表去重
|
|
|
elif str(video_title) in [x for y in Feishu.get_values_batch(log_type, 'shipinhao', 'FSDlBy') for x in y]:
|
|
|
- Common.logger(log_type).info('向上滑动页面')
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
- Common.logger(log_type).info('视频已存在\n')
|
|
|
+ Common.logger(log_type).info('视频已存在,滑动到下一个视频\n')
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
|
|
|
# 分享给 windows 爬虫机
|
|
|
else:
|
|
@@ -215,16 +197,6 @@ class Recommend:
|
|
|
driver.find_element(By.XPATH, '//*[@text="爬虫群"]').click()
|
|
|
driver.find_element(By.ID, 'com.tencent.mm:id/guw').click()
|
|
|
|
|
|
- # Click.click_video(log_type, video_title)
|
|
|
- # time.sleep(1)
|
|
|
-
|
|
|
- # urls = GetUrl.get_url(log_type)
|
|
|
- # if urls is None:
|
|
|
- # Common.logger(log_type).info('未获取到视频 URL')
|
|
|
- # else:
|
|
|
- # video_url = urls[0]
|
|
|
- # cover_url = urls[1]
|
|
|
-
|
|
|
# 把视频信息写入飞书feeds文档
|
|
|
Feishu.insert_columns(log_type, 'shipinhao', 'FSDlBy', 'ROWS', 1, 2)
|
|
|
get_feeds_time = int(time.time())
|
|
@@ -239,8 +211,6 @@ class Recommend:
|
|
|
str(user_name)]]
|
|
|
time.sleep(1)
|
|
|
Feishu.update_values(log_type, 'shipinhao', 'FSDlBy', 'A2:Z2', values)
|
|
|
- Common.logger(log_type).info('向上滑动页面')
|
|
|
- # driver.swipe(500, 1500, 500, 500, 300)
|
|
|
Common.logger(log_type).info('视频信息写入飞书文档成功\n')
|
|
|
|
|
|
while True:
|
|
@@ -248,12 +218,12 @@ class Recommend:
|
|
|
Common.logger(log_type).info('等待更新 URL 信息')
|
|
|
time.sleep(10)
|
|
|
else:
|
|
|
- Common.logger(log_type).info('URL 信息已更新\n')
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
+ Common.logger(log_type).info('URL 信息已更新,滑动到下一个视频\n')
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
break
|
|
|
except Exception as e:
|
|
|
- Common.logger(log_type).error('get_feeds异常\n', e)
|
|
|
- driver.swipe(500, 1500, 500, 500, 300)
|
|
|
+ Common.logger(log_type).error('get_feeds异常,滑动到下一个视频\n', e)
|
|
|
+ driver.swipe(10, 1600, 10, 300, 200)
|
|
|
|
|
|
# 下载 、上传
|
|
|
@classmethod
|