lierqiang 2 年之前
父節點
當前提交
a909df5890
共有 3 個文件被更改,包括 111 次插入102 次删除
  1. 14 15
      douyin/douyin_follow/follow_dy.py
  2. 1 9
      kuaishou/kuaishou_follow/kuaishou_follow.py
  3. 96 78
      xigua/xigua_follow/xigua_follow.py

+ 14 - 15
douyin/douyin_follow/follow_dy.py

@@ -12,6 +12,7 @@ from hashlib import md5
 
 from common.public import get_user_from_mysql
 from douyin.douyin_recommend import get_xb
+
 sys.path.append(os.getcwd())
 from common.db import MysqlHelper
 from common.feishu import Feishu
@@ -143,7 +144,8 @@ class DyFollow(object):
 
         try:
             max_cursor = ''
-            url = "https://www.douyin.com/aweme/v1/web/aweme/post/?device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id={sec_user_id}&max_cursor={max_cursor}&show_live_replay_strategy=1&count=10&publish_video_strategy_type=2&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1440&screen_height=900&browser_language=zh-CN&browser_platform=MacIntel&browser_name=Chrome&browser_version=112.0.0.0&browser_online=true&engine_name=Blink&engine_version=112.0.0.0&os_name=Mac+OS&os_version=10.15.7&cpu_core_num=8&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50".format(sec_user_id=out_uid, max_cursor=max_cursor)
+            url = "https://www.douyin.com/aweme/v1/web/aweme/post/?device_platform=webapp&aid=6383&channel=channel_pc_web&sec_user_id={sec_user_id}&max_cursor={max_cursor}&show_live_replay_strategy=1&count=10&publish_video_strategy_type=2&pc_client_type=1&version_code=170400&version_name=17.4.0&cookie_enabled=true&screen_width=1440&screen_height=900&browser_language=zh-CN&browser_platform=MacIntel&browser_name=Chrome&browser_version=112.0.0.0&browser_online=true&engine_name=Blink&engine_version=112.0.0.0&os_name=Mac+OS&os_version=10.15.7&cpu_core_num=8&device_memory=8&platform=PC&downlink=10&effective_type=4g&round_trip_time=50".format(
+                sec_user_id=out_uid, max_cursor=max_cursor)
             headers = {
                 'authority': 'www.douyin.com',
                 'accept': 'application/json, text/plain, */*',
@@ -353,20 +355,17 @@ class DyFollow(object):
             user_name = user["nick_name"]
             our_uid = user["media_id"]
             Common.logger(log_type, crawler).info(f"开始抓取 {user_name} 用户主页视频\n")
-            try:
-                cls.get_videoList(log_type=log_type,
-                                  crawler=crawler,
-                                  strategy=strategy,
-                                  our_uid=our_uid,
-                                  out_uid=out_uid,
-                                  oss_endpoint=oss_endpoint,
-                                  env=env,
-                                  machine=machine,
-                                  rule_dict=rule_dict,
-                                  )
-            except Exception as e:
-                Common.logger(log_type, crawler).error(f"get_follow_videos:{e}\n")
+            cls.get_videoList(log_type=log_type,
+                              crawler=crawler,
+                              strategy=strategy,
+                              our_uid=our_uid,
+                              out_uid=out_uid,
+                              oss_endpoint=oss_endpoint,
+                              env=env,
+                              machine=machine,
+                              rule_dict=rule_dict,
+                              )
 
 
 if __name__ == '__main__':
-    DyFollow.get_follow_videos('author','douyin', '定向抓取策略','outer','prod', 'aliyun')
+    DyFollow.get_follow_videos('author', 'douyin', '定向抓取策略', 'outer', 'prod', 'aliyun')

+ 1 - 9
kuaishou/kuaishou_follow/kuaishou_follow.py

@@ -668,8 +668,7 @@ class KuaiShouFollow:
             user_name = user["nick_name"]
             our_uid = user["media_id"]
             Common.logger(log_type, crawler).info(f"开始抓取 {user_name} 用户主页视频\n")
-            try:
-                cls.get_videoList(log_type=log_type,
+            cls.get_videoList(log_type=log_type,
                                   crawler=crawler,
                                   strategy=strategy,
                                   our_uid=our_uid,
@@ -677,13 +676,6 @@ class KuaiShouFollow:
                                   oss_endpoint=oss_endpoint,
                                   env=env,
                                   machine=machine)
-            except Exception as e:
-                Common.logger(log_type, crawler).info(f"用户:{user_name}, 抓取异常:{e}\n")
-                continue
-            # sleep_time = random.randint(1,3)
-            # Common.logger(log_type, crawler).info(f"休眠{sleep_time}秒\n")
-            # time.sleep(sleep_time)
-
 
 if __name__ == "__main__":
     KuaiShouFollow.get_videoList(log_type="follow",

+ 96 - 78
xigua/xigua_follow/xigua_follow.py

@@ -103,9 +103,10 @@ class Follow:
     @classmethod
     def get_out_user_info(cls, log_type, crawler, out_uid):
         try:
-            headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41',
-                       'referer': f'https://www.ixigua.com/home/{out_uid}',
-                       'Cookie': f'ixigua-a-s=1; support_webp=true; support_avif=false; csrf_session_id=a5355d954d3c63ed1ba35faada452b4d; __ac_signature={cls.random_signature()}; MONITOR_WEB_ID=67cb5099-a022-4ec3-bb8e-c4de6ba51dd0; s_v_web_id=verify_lef4i99x_32SosrdH_Qrtk_4LJn_8S7q_fhu16xe3s8ZV; tt_scid=QLJjPuHf6wxVqu6IIq6gHiJXQpVrCwrdhjH2zpm7-E3ZniE1RXBcP6M8b41FJOdo41e1; ttwid=1%7CHHtv2QqpSGuSu8r-zXF1QoWsvjmNi1SJrqOrZzg-UCY%7C1677047013%7C5866a444e5ae10a9df8c11551db75010fb77b657f214ccf84e503fae8d313d09; msToken=PerXJcDdIsZ6zXkGITsftXX4mDaVaW21GuqtzSVdctH46oXXT2GcELIs9f0XW2hunRzP6KVHLZaYElRvNYflLKUXih7lC27XKxs3HjdZiXPK9NQaoKbLfA==; ixigua-a-s=1',}
+            headers = {
+                'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41',
+                'referer': f'https://www.ixigua.com/home/{out_uid}',
+                'Cookie': f'ixigua-a-s=1; support_webp=true; support_avif=false; csrf_session_id=a5355d954d3c63ed1ba35faada452b4d; __ac_signature={cls.random_signature()}; MONITOR_WEB_ID=67cb5099-a022-4ec3-bb8e-c4de6ba51dd0; s_v_web_id=verify_lef4i99x_32SosrdH_Qrtk_4LJn_8S7q_fhu16xe3s8ZV; tt_scid=QLJjPuHf6wxVqu6IIq6gHiJXQpVrCwrdhjH2zpm7-E3ZniE1RXBcP6M8b41FJOdo41e1; ttwid=1%7CHHtv2QqpSGuSu8r-zXF1QoWsvjmNi1SJrqOrZzg-UCY%7C1677047013%7C5866a444e5ae10a9df8c11551db75010fb77b657f214ccf84e503fae8d313d09; msToken=PerXJcDdIsZ6zXkGITsftXX4mDaVaW21GuqtzSVdctH46oXXT2GcELIs9f0XW2hunRzP6KVHLZaYElRvNYflLKUXih7lC27XKxs3HjdZiXPK9NQaoKbLfA==; ixigua-a-s=1', }
             url = f"https://www.ixigua.com/home/{out_uid}"
             urllib3.disable_warnings()
             s = requests.session()
@@ -114,20 +115,23 @@ class Follow:
             s.mount('https://', HTTPAdapter(max_retries=3))
             response = s.get(url=url, headers=headers, proxies=Common.tunnel_proxies(), verify=False, timeout=5).text
             html = etree.HTML(response)
-            out_follow_str = html.xpath('//div[@class="userDetailV3__header__detail2"]/*[1]/span')[0].text.encode('raw_unicode_escape').decode()
-            out_fans_str = html.xpath('//div[@class="userDetailV3__header__detail2"]/*[2]/span')[0].text.encode('raw_unicode_escape').decode()
-            out_like_str = html.xpath('//div[@class="userDetailV3__header__detail2"]/*[3]/span')[0].text.encode('raw_unicode_escape').decode()
+            out_follow_str = html.xpath('//div[@class="userDetailV3__header__detail2"]/*[1]/span')[0].text.encode(
+                'raw_unicode_escape').decode()
+            out_fans_str = html.xpath('//div[@class="userDetailV3__header__detail2"]/*[2]/span')[0].text.encode(
+                'raw_unicode_escape').decode()
+            out_like_str = html.xpath('//div[@class="userDetailV3__header__detail2"]/*[3]/span')[0].text.encode(
+                'raw_unicode_escape').decode()
             out_avatar_url = f"""https:{html.xpath('//span[@class="component-avatar__inner"]//img/@src')[0]}"""
             if "万" in out_follow_str:
-                out_follow = int(float(out_follow_str.split("万")[0])*10000)
+                out_follow = int(float(out_follow_str.split("万")[0]) * 10000)
             else:
                 out_follow = int(out_follow_str.replace(",", ""))
             if "万" in out_fans_str:
-                out_fans = int(float(out_fans_str.split("万")[0])*10000)
+                out_fans = int(float(out_fans_str.split("万")[0]) * 10000)
             else:
                 out_fans = int(out_fans_str.replace(",", ""))
             if "万" in out_like_str:
-                out_like = int(float(out_like_str.split("万")[0])*10000)
+                out_like = int(float(out_like_str.split("万")[0]) * 10000)
             else:
                 out_like = int(out_like_str.replace(",", ""))
             out_user_dict = {
@@ -153,7 +157,7 @@ class Follow:
                     continue
                 our_user_list = []
                 for i in range(1, len(user_sheet)):
-                # for i in range(428, len(user_sheet)):
+                    # for i in range(428, len(user_sheet)):
                     out_uid = user_sheet[i][2]
                     user_name = user_sheet[i][3]
                     our_uid = user_sheet[i][6]
@@ -181,10 +185,12 @@ class Follow:
                                 "platform": cls.platform,
                                 "tag": cls.tag,
                             }
-                            our_user_dict = getUser.create_user(log_type=log_type, crawler=crawler, out_user_dict=out_user_dict, env=env, machine=machine)
+                            our_user_dict = getUser.create_user(log_type=log_type, crawler=crawler,
+                                                                out_user_dict=out_user_dict, env=env, machine=machine)
                             our_uid = our_user_dict['our_uid']
                             our_user_link = our_user_dict['our_user_link']
-                            Feishu.update_values(log_type, crawler, sheetid, f'G{i + 1}:H{i + 1}', [[our_uid, our_user_link]])
+                            Feishu.update_values(log_type, crawler, sheetid, f'G{i + 1}:H{i + 1}',
+                                                 [[our_uid, our_user_link]])
                             Common.logger(log_type, crawler).info(f'站内用户信息写入飞书成功!\n')
                             our_user_list.append(our_user_dict)
                         else:
@@ -301,7 +307,8 @@ class Follow:
             # max_retries=3 重试3次
             s.mount('http://', HTTPAdapter(max_retries=3))
             s.mount('https://', HTTPAdapter(max_retries=3))
-            response = s.get(url=url, headers=headers, params=params, cookies=cookies, verify=False, proxies=Common.tunnel_proxies(), timeout=5)
+            response = s.get(url=url, headers=headers, params=params, cookies=cookies, verify=False,
+                             proxies=Common.tunnel_proxies(), timeout=5)
             response.close()
             if 'data' not in response.json() or response.json()['data'] == '':
                 Common.logger(log_type, crawler).warning('get_video_info: response: {}', response)
@@ -316,7 +323,8 @@ class Follow:
                     video_url_dict["video_height"] = 0
 
                 elif 'dash_120fps' in video_info['videoResource']:
-                    if "video_list" in video_info['videoResource']['dash_120fps'] and 'video_4' in video_info['videoResource']['dash_120fps']['video_list']:
+                    if "video_list" in video_info['videoResource']['dash_120fps'] and 'video_4' in \
+                            video_info['videoResource']['dash_120fps']['video_list']:
                         video_url = video_info['videoResource']['dash_120fps']['video_list']['video_4']['backup_url_1']
                         audio_url = video_info['videoResource']['dash_120fps']['video_list']['video_4']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -335,7 +343,8 @@ class Follow:
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
                         video_url_dict["video_height"] = video_height
-                    elif "video_list" in video_info['videoResource']['dash_120fps'] and 'video_3' in video_info['videoResource']['dash_120fps']['video_list']:
+                    elif "video_list" in video_info['videoResource']['dash_120fps'] and 'video_3' in \
+                            video_info['videoResource']['dash_120fps']['video_list']:
                         video_url = video_info['videoResource']['dash_120fps']['video_list']['video_3']['backup_url_1']
                         audio_url = video_info['videoResource']['dash_120fps']['video_list']['video_3']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -354,7 +363,8 @@ class Follow:
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
                         video_url_dict["video_height"] = video_height
-                    elif "video_list" in video_info['videoResource']['dash_120fps'] and 'video_2' in video_info['videoResource']['dash_120fps']['video_list']:
+                    elif "video_list" in video_info['videoResource']['dash_120fps'] and 'video_2' in \
+                            video_info['videoResource']['dash_120fps']['video_list']:
                         video_url = video_info['videoResource']['dash_120fps']['video_list']['video_2']['backup_url_1']
                         audio_url = video_info['videoResource']['dash_120fps']['video_list']['video_2']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -373,7 +383,8 @@ class Follow:
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
                         video_url_dict["video_height"] = video_height
-                    elif "video_list" in video_info['videoResource']['dash_120fps'] and 'video_1' in video_info['videoResource']['dash_120fps']['video_list']:
+                    elif "video_list" in video_info['videoResource']['dash_120fps'] and 'video_1' in \
+                            video_info['videoResource']['dash_120fps']['video_list']:
                         video_url = video_info['videoResource']['dash_120fps']['video_list']['video_1']['backup_url_1']
                         audio_url = video_info['videoResource']['dash_120fps']['video_list']['video_1']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -396,11 +407,17 @@ class Follow:
                     elif 'dynamic_video' in video_info['videoResource']['dash_120fps'] \
                             and 'dynamic_video_list' in video_info['videoResource']['dash_120fps']['dynamic_video'] \
                             and 'dynamic_audio_list' in video_info['videoResource']['dash_120fps']['dynamic_video'] \
-                            and len(video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list']) != 0 \
-                            and len(video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_audio_list']) != 0:
+                            and len(
+                        video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list']) != 0 \
+                            and len(
+                        video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_audio_list']) != 0:
 
-                        video_url = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1]['backup_url_1']
-                        audio_url = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_audio_list'][-1]['backup_url_1']
+                        video_url = \
+                        video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1][
+                            'backup_url_1']
+                        audio_url = \
+                        video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_audio_list'][-1][
+                            'backup_url_1']
                         if len(video_url) % 3 == 1:
                             video_url += '=='
                         elif len(video_url) % 3 == 2:
@@ -411,8 +428,10 @@ class Follow:
                             audio_url += '='
                         video_url = base64.b64decode(video_url).decode('utf8')
                         audio_url = base64.b64decode(audio_url).decode('utf8')
-                        video_width = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1]['vwidth']
-                        video_height = video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1]['vheight']
+                        video_width = \
+                        video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1]['vwidth']
+                        video_height = \
+                        video_info['videoResource']['dash_120fps']['dynamic_video']['dynamic_video_list'][-1]['vheight']
                         video_url_dict["video_url"] = video_url
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
@@ -424,7 +443,8 @@ class Follow:
                         video_url_dict["video_height"] = 0
 
                 elif 'dash' in video_info['videoResource']:
-                    if "video_list" in video_info['videoResource']['dash'] and 'video_4' in video_info['videoResource']['dash']['video_list']:
+                    if "video_list" in video_info['videoResource']['dash'] and 'video_4' in \
+                            video_info['videoResource']['dash']['video_list']:
                         video_url = video_info['videoResource']['dash']['video_list']['video_4']['backup_url_1']
                         audio_url = video_info['videoResource']['dash']['video_list']['video_4']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -443,7 +463,8 @@ class Follow:
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
                         video_url_dict["video_height"] = video_height
-                    elif "video_list" in video_info['videoResource']['dash'] and 'video_3' in video_info['videoResource']['dash']['video_list']:
+                    elif "video_list" in video_info['videoResource']['dash'] and 'video_3' in \
+                            video_info['videoResource']['dash']['video_list']:
                         video_url = video_info['videoResource']['dash']['video_list']['video_3']['backup_url_1']
                         audio_url = video_info['videoResource']['dash']['video_list']['video_3']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -462,7 +483,8 @@ class Follow:
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
                         video_url_dict["video_height"] = video_height
-                    elif "video_list" in video_info['videoResource']['dash'] and 'video_2' in video_info['videoResource']['dash']['video_list']:
+                    elif "video_list" in video_info['videoResource']['dash'] and 'video_2' in \
+                            video_info['videoResource']['dash']['video_list']:
                         video_url = video_info['videoResource']['dash']['video_list']['video_2']['backup_url_1']
                         audio_url = video_info['videoResource']['dash']['video_list']['video_2']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -481,7 +503,8 @@ class Follow:
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
                         video_url_dict["video_height"] = video_height
-                    elif "video_list" in video_info['videoResource']['dash'] and 'video_1' in video_info['videoResource']['dash']['video_list']:
+                    elif "video_list" in video_info['videoResource']['dash'] and 'video_1' in \
+                            video_info['videoResource']['dash']['video_list']:
                         video_url = video_info['videoResource']['dash']['video_list']['video_1']['backup_url_1']
                         audio_url = video_info['videoResource']['dash']['video_list']['video_1']['backup_url_1']
                         if len(video_url) % 3 == 1:
@@ -507,8 +530,10 @@ class Follow:
                             and len(video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list']) != 0 \
                             and len(video_info['videoResource']['dash']['dynamic_video']['dynamic_audio_list']) != 0:
 
-                        video_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1]['backup_url_1']
-                        audio_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_audio_list'][-1]['backup_url_1']
+                        video_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
+                            'backup_url_1']
+                        audio_url = video_info['videoResource']['dash']['dynamic_video']['dynamic_audio_list'][-1][
+                            'backup_url_1']
                         if len(video_url) % 3 == 1:
                             video_url += '=='
                         elif len(video_url) % 3 == 2:
@@ -519,8 +544,10 @@ class Follow:
                             audio_url += '='
                         video_url = base64.b64decode(video_url).decode('utf8')
                         audio_url = base64.b64decode(audio_url).decode('utf8')
-                        video_width = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1]['vwidth']
-                        video_height = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1]['vheight']
+                        video_width = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
+                            'vwidth']
+                        video_height = video_info['videoResource']['dash']['dynamic_video']['dynamic_video_list'][-1][
+                            'vheight']
                         video_url_dict["video_url"] = video_url
                         video_url_dict["audio_url"] = audio_url
                         video_url_dict["video_width"] = video_width
@@ -676,28 +703,16 @@ class Follow:
                     '_signature': signature,
                 }
                 headers = {
-                    # 'authority': 'www.ixigua.com',
-                    # 'accept': 'application/json, text/plain, */*',
-                    # 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
-                    # 'cache-control': 'no-cache',
-                    # 'cookie': f'MONITOR_WEB_ID=7168304743566296612; __ac_signature={signature}; ixigua-a-s=1; support_webp=true; support_avif=false; csrf_session_id=a5355d954d3c63ed1ba35faada452b4d; msToken=G0eRzNkw189a8TLaXjc6nTHVMQwh9XcxVAqTbGKi7iPJdQcLwS3-XRrJ3MZ7QBfqErpxp3EX1WtvWOIcZ3NIgr41hgcd-v64so_RRj3YCRw1UsKW8mIssNLlIMspsg==; tt_scid=o4agqz7u9SKPwfBoPt6S82Cw0q.9KDtqmNe0JHxMqmpxNHQWq1BmrQdgVU6jEoX7ed99; ttwid=1%7CHHtv2QqpSGuSu8r-zXF1QoWsvjmNi1SJrqOrZzg-UCY%7C1676618894%7Cee5ad95378275f282f230a7ffa9947ae7eff40d0829c5a2568672a6dc90a1c96; ixigua-a-s=1',
-                    # 'pragma': 'no-cache',
                     'referer': f'https://www.ixigua.com/home/{out_uid}/video/?preActiveKey=hotsoon&list_entrance=userdetail',
-                    # 'sec-ch-ua': '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
-                    # 'sec-ch-ua-mobile': '?0',
-                    # 'sec-ch-ua-platform': '"macOS"',
-                    # 'sec-fetch-dest': 'empty',
-                    # 'sec-fetch-mode': 'cors',
-                    # 'sec-fetch-site': 'same-origin',
                     'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41',
-                    # 'x-secsdk-csrf-token': '00010000000119e3f9454d1dcbb288704cda1960f241e2d19bd21f2fd283520c3615a990ac5a17448bfbb902a249'
                 }
                 urllib3.disable_warnings()
                 s = requests.session()
                 # max_retries=3 重试3次
                 s.mount('http://', HTTPAdapter(max_retries=3))
                 s.mount('https://', HTTPAdapter(max_retries=3))
-                response = s.get(url=url, headers=headers, params=params, proxies=Common.tunnel_proxies(), verify=False, timeout=5)
+                response = s.get(url=url, headers=headers, params=params, proxies=Common.tunnel_proxies(), verify=False,
+                                 timeout=5)
                 response.close()
                 cls.offset += 30
                 if response.status_code != 200:
@@ -720,7 +735,7 @@ class Follow:
                             video_title = 0
                         else:
                             video_title = videoList[i]['title'].strip().replace('手游', '') \
-                                .replace('/', '').replace('\/', '').replace('\n', '').replace('"' ,'').replace("'", '')
+                                .replace('/', '').replace('\/', '').replace('\n', '').replace('"', '').replace("'", '')
 
                         # video_id
                         if 'video_id' not in videoList[i]:
@@ -809,7 +824,8 @@ class Follow:
                         elif 'url' in videoList[i]['video_detail_info']['detail_video_large_image']:
                             cover_url = videoList[i]['video_detail_info']['detail_video_large_image']['url']
                         else:
-                            cover_url = videoList[i]['video_detail_info']['detail_video_large_image']['url_list'][0]['url']
+                            cover_url = videoList[i]['video_detail_info']['detail_video_large_image']['url_list'][0][
+                                'url']
 
                         Common.logger(log_type, crawler).info(f'---开始读取规则---')
                         rule_dict = cls.get_rule(log_type, crawler)
@@ -817,10 +833,13 @@ class Follow:
 
                         if gid == 0 or video_id == 0 or cover_url == 0:
                             Common.logger(log_type, crawler).info('无效视频\n')
-                        elif is_top is True and int(time.time()) - int(publish_time) > 3600 * 24 * rule_dict['publish_time']:
-                            Common.logger(log_type, crawler).info(f'置顶视频,且发布时间:{publish_time_str} 超过{rule_dict["publish_time"]}天\n')
+                        elif is_top is True and int(time.time()) - int(publish_time) > 3600 * 24 * rule_dict[
+                            'publish_time']:
+                            Common.logger(log_type, crawler).info(
+                                f'置顶视频,且发布时间:{publish_time_str} 超过{rule_dict["publish_time"]}天\n')
                         elif int(time.time()) - int(publish_time) > 3600 * 24 * rule_dict['publish_time']:
-                            Common.logger(log_type, crawler).info(f'发布时间:{publish_time_str}超过{rule_dict["publish_time"]}天\n')
+                            Common.logger(log_type, crawler).info(
+                                f'发布时间:{publish_time_str}超过{rule_dict["publish_time"]}天\n')
                             cls.offset = 0
                             return
                         else:
@@ -876,7 +895,8 @@ class Follow:
         try:
             if cls.download_rule(video_dict, rule_dict) is False:
                 Common.logger(log_type, crawler).info('不满足抓取规则\n')
-            elif any(word if word in video_dict['video_title'] else False for word in cls.filter_words(log_type, crawler)) is True:
+            elif any(word if word in video_dict['video_title'] else False for word in
+                     cls.filter_words(log_type, crawler)) is True:
                 Common.logger(log_type, crawler).info('标题已中过滤词:{}\n', video_dict['video_title'])
             elif cls.repeat_video(log_type, crawler, video_dict['video_id'], env, machine) != 0:
                 Common.logger(log_type, crawler).info('视频已下载\n')
@@ -890,11 +910,14 @@ class Follow:
             #     Common.logger(log_type, crawler).info('视频已存在\n')
             else:
                 # 下载视频
-                Common.download_method(log_type=log_type, crawler=crawler, text='xigua_video', title=video_dict['video_title'], url=video_dict['video_url'])
+                Common.download_method(log_type=log_type, crawler=crawler, text='xigua_video',
+                                       title=video_dict['video_title'], url=video_dict['video_url'])
                 # 下载音频
-                Common.download_method(log_type=log_type, crawler=crawler, text='xigua_audio', title=video_dict['video_title'], url=video_dict['audio_url'])
+                Common.download_method(log_type=log_type, crawler=crawler, text='xigua_audio',
+                                       title=video_dict['video_title'], url=video_dict['audio_url'])
                 # 合成音视频
-                Common.video_compose(log_type=log_type, crawler=crawler, video_dir=f"./{crawler}/videos/{video_dict['video_title']}")
+                Common.video_compose(log_type=log_type, crawler=crawler,
+                                     video_dir=f"./{crawler}/videos/{video_dict['video_title']}")
                 md_title = md5(video_dict['video_title'].encode('utf8')).hexdigest()
                 if os.path.getsize(f"./{crawler}/videos/{md_title}/video.mp4") == 0:
                     # 删除视频文件夹
@@ -908,7 +931,8 @@ class Follow:
                 #     shutil.rmtree(f"./{crawler}/videos/{video_dict['video_title']}")
                 #     return
                 # 下载封面
-                Common.download_method(log_type=log_type, crawler=crawler, text='cover', title=video_dict['video_title'], url=video_dict['cover_url'])
+                Common.download_method(log_type=log_type, crawler=crawler, text='cover',
+                                       title=video_dict['video_title'], url=video_dict['cover_url'])
                 # 保存视频信息至txt
                 Common.save_video_info(log_type=log_type, crawler=crawler, video_dict=video_dict)
 
@@ -996,30 +1020,24 @@ class Follow:
 
     @classmethod
     def get_follow_videos(cls, log_type, crawler, strategy, oss_endpoint, env, machine):
-        try:
-            # user_list = cls.get_user_list(log_type=log_type, crawler=crawler, sheetid="5tlTYB", env=env, machine=machine)
-            user_list = get_user_from_mysql(log_type, crawler, crawler, env)
-
-            for user in user_list:
-                spider_link = user["spider_link"]
-                out_uid = spider_link.split('/')[-1]
-                user_name = user["nick_name"]
-                our_uid = user["media_id"]
+        user_list = get_user_from_mysql(log_type, crawler, crawler, env)
+        for user in user_list:
+            spider_link = user["spider_link"]
+            out_uid = spider_link.split('/')[-1]
+            user_name = user["nick_name"]
+            our_uid = user["media_id"]
 
-                Common.logger(log_type, crawler).info(f"开始抓取 {user_name} 用户主页视频\n")
-                cls.get_videolist(log_type=log_type,
-                                  crawler=crawler,
-                                  strategy=strategy,
-                                  our_uid=our_uid,
-                                  out_uid=out_uid,
-                                  oss_endpoint=oss_endpoint,
-                                  env=env,
-                                  machine=machine)
-                cls.offset = 0
-                time.sleep(1)
-        except Exception as e:
-            Common.logger(log_type, crawler).error(f"get_follow_videos:{e}\n")
+            Common.logger(log_type, crawler).info(f"开始抓取 {user_name} 用户主页视频\n")
+            cls.get_videolist(log_type=log_type,
+                              crawler=crawler,
+                              strategy=strategy,
+                              our_uid=our_uid,
+                              out_uid=out_uid,
+                              oss_endpoint=oss_endpoint,
+                              env=env,
+                              machine=machine)
+            cls.offset = 0
 
 
 if __name__ == '__main__':
-    Follow.get_follow_videos('follow','xigua','定向抓取策略', 'inner','prod', 'aliyun')
+    Follow.get_follow_videos('follow', 'xigua', '定向抓取策略', 'inner', 'prod', 'aliyun')