From 70d17e0f34cbbef4cd43aed1fd5735879c9e86f9 Mon Sep 17 00:00:00 2001 From: frxz751113 <156018267+frxz751113@users.noreply.github.com> Date: Mon, 30 Sep 2024 02:51:26 +0800 Subject: [PATCH] Update GAT.py --- py/GAT.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/GAT.py b/py/GAT.py index 86c7ac4..7bb1736 100644 --- a/py/GAT.py +++ b/py/GAT.py @@ -19,18 +19,18 @@ output_file = 'gat.txt' keywords = ['凤凰卫视', '人间卫视', '香港卫视'] # 这里定义你的搜索关键词列表 output_file = 'gat.txt' - with open(output_file, 'w', encoding='utf-8') as f: for keyword in keywords: url = f'http://tonkiang.us/?&iqtv={keyword}' response = requests.get(url) if response.status_code == 200: - # 使用BeautifulSoup解析网页内容并提取文本 soup = BeautifulSoup(response.text, 'html.parser') text_content = soup.get_text() f.write(text_content + '\n') else: print(f'请求 {url} 失败,状态码:{response.status_code}') + time.sleep(1) # 添加 1 秒的延迟 + with open('gat.txt', 'r', encoding='utf-8') as infile: