Update GAT.py
This commit is contained in:
@@ -19,15 +19,15 @@ output_file = 'gat.txt'
|
|||||||
|
|
||||||
with open(output_file, 'w', encoding='utf-8') as f:
|
with open(output_file, 'w', encoding='utf-8') as f:
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
url = f'http://tonkiang.us/?&iqtv={keyword}'
|
for page in range(1, 11):
|
||||||
response = requests.get(url)
|
url = f'http://tonkiang.us/?page={page}&iqtv={keyword}'
|
||||||
if response.status_code == 200:
|
response = requests.get(url)
|
||||||
# 使用BeautifulSoup解析网页内容并提取文本
|
if response.status_code == 200:
|
||||||
soup = BeautifulSoup(response.text, 'html.parser')
|
soup = BeautifulSoup(response.text, 'html.parser')
|
||||||
text_content = soup.get_text()
|
text_content = soup.get_text()
|
||||||
f.write(text_content + '\n')
|
f.write(text_content + '\n')
|
||||||
else:
|
else:
|
||||||
print(f'请求 {url} 失败,状态码:{response.status_code}')
|
print(f'请求 {url} 失败,状态码:{response.status_code}')
|
||||||
|
|
||||||
|
|
||||||
with open('gat.txt', 'r', encoding='utf-8') as infile:
|
with open('gat.txt', 'r', encoding='utf-8') as infile:
|
||||||
|
|||||||
Reference in New Issue
Block a user