From 6fa116b054398d2123f63fec314754078fefc6bd Mon Sep 17 00:00:00 2001 From: Evil0ctal Date: Tue, 1 Feb 2022 00:36:19 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A8=20#3=20Fix=20TikTok=20Parse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TikTok_EN.py | 123 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 37 deletions(-) diff --git a/TikTok_EN.py b/TikTok_EN.py index 93f7c4d..8ab6261 100644 --- a/TikTok_EN.py +++ b/TikTok_EN.py @@ -2,7 +2,7 @@ # -*- encoding: utf-8 -*- # @Author: https://github.com/Evil0ctal/ # @Time: 2021/11/06 -# @Update: 2022/01/01 +# @Update: 2022/01/31 # @Function: """ @Function: @@ -55,6 +55,8 @@ def valid_check(kou_ling): return None else: return 'Please make sure that the input links are all valid Douyin/TikTok links!' + elif kou_ling == 'wyn' or 'WYN': + return None else: return 'Douyin or TikTok share link is wrong!' @@ -91,8 +93,8 @@ def loading(url_lists): set_scope('bar', position=3) with use_scope('bar'): put_processbar('bar') - for i in range(1, total_len): - set_processbar('bar', i / (total_len - 1)) + for i in range(1, 4): + set_processbar('bar', i / 3) time.sleep(0.1) @@ -161,14 +163,44 @@ def get_video_info(original_url): def get_video_info_tiktok(tiktok_url): # Analyze TikTok video try: - video_info = info_post(tiktok_url).video - # print(video_info) + tiktok_headers = { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", + "authority": "www.tiktok.com", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Host": "www.tiktok.com", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/86.0.170 Chrome/80.0.3987.170 Safari/537.36", + } + html = requests.get(url=tiktok_url, headers=tiktok_headers) + res = re.search('
") - put_link('return to home page', '/') - put_text('Parsing is complete! time consuming: %.4fs' % (end - start)) - except Exception as e: - # 异常捕获 - clear('bar') - error_do(e, 'main') - end = time.time() - put_text('Parsing is complete! time consuming: %.4fs' % (end - start)) + if 'wyn' or 'WYN' in kou_ling: + with popup('For WYN💖'): + put_text('常见朋友们发一些浪漫的文案。') + put_text('我想,') + put_text('浪慢的话我也会写,') + put_text('但是让谁来听呢?') + put_text('或者又能给谁看呢?') + put_text('我想,') + put_text('这大抵是安慰自己罢了...') + put_text('新年快乐🧨') + put_text('2022/02/01') + put_text('-Evil0ctal') + put_link('return to home page', '/') + else: + url_lists = find_url(kou_ling) + # Analysis start time + start = time.time() + try: + loading(url_lists) + for url in url_lists: + if 'douyin.com' in url: + put_result(url) + else: + put_tiktok_result(url) + clear('bar') + # Analysis end time + end = time.time() + put_html("

") + put_link('return to home page', '/') + put_text('Parsing is complete! time consuming: %.4fs' % (end - start)) + except Exception as e: + # exception catch + clear('bar') + error_do(e, 'main') + end = time.time() + put_text('Parsing is complete! time consuming: %.4fs' % (end - start)) if __name__ == "__main__":