onlyou13

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
        def _read_urls(self):
            filename = 'd:\\youtube.txt'
            with open(filename, 'r', encoding='utf-8') as f:
                urls = f.readlines()

                count = 0
                age_limit_count = 0
                for url in urls:
                    try:
                        count += 1
                        if url.find('v=') < 0:
                            continue
                        url = url.split("&")[0]
                        vid = re.findall(r'v\=(.+)', url)[0]
                        print(vid)
                        video_webpage = self._download_webpage(url, vid)
                        if 'age_restrictions' in video_webpage:
                            age_limit_count += 1
                        elif 'Age-restricted' in video_webpage:
                            age_limit_count += 1
                    except Exception as e:
                        print(e)
                print(age_limit_count)

 

posted on 2023-04-17 17:50  onlyou13  阅读(38)  评论(0编辑  收藏  举报