|
@@ -7,6 +7,7 @@ import sys
|
|
|
import time
|
|
|
from hashlib import md5
|
|
|
|
|
|
+import requests
|
|
|
from appium import webdriver
|
|
|
from appium.webdriver.extensions.android.nativekey import AndroidKey
|
|
|
from appium.webdriver.webdriver import WebDriver
|
|
@@ -22,6 +23,13 @@ from common.public import download_rule, get_config_from_mysql
|
|
|
from common.scheduling_db import MysqlHelper
|
|
|
|
|
|
|
|
|
+def get_redirect_url(url):
|
|
|
+ res = requests.get(url, allow_redirects=False)
|
|
|
+ if res.status_code == 302 or res.status_code == 301:
|
|
|
+ return res.headers['Location']
|
|
|
+ else:
|
|
|
+ return url
|
|
|
+
|
|
|
class XiaoNianGaoPlusRecommend:
|
|
|
env = None
|
|
|
driver = None
|
|
@@ -276,6 +284,7 @@ class XiaoNianGaoPlusRecommend:
|
|
|
Common.logger(self.log_type, self.crawler).info("点击标题,进入视频详情页")
|
|
|
Common.logging(self.log_type, self.crawler, self.env, "点击标题,进入视频详情页")
|
|
|
video_url = self.get_video_url(video_title_element)
|
|
|
+ video_url = get_redirect_url(video_url)
|
|
|
if video_url is None:
|
|
|
Common.logger(self.log_type, self.crawler).info("未获取到视频播放地址\n")
|
|
|
self.driver.press_keycode(AndroidKey.BACK)
|