File size: 825 Bytes
cac3c50
877f335
ef4b057
877f335
 
 
ef4b057
877f335
 
 
 
 
 
 
ef4b057
877f335
ef4b057
877f335
ef4b057
877f335
 
 
 
 
ef4b057
877f335
4a989fc
877f335
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import requests
from bs4 import BeautifulSoup

def search_team_info(team_name):
    search_query = f"足球 {team_name} 隊 資料"
    search_results = []

    # 使用 Google 搜尋引擎 API 搜尋資料
    google_url = f"https://www.google.com/search?q={search_query}"
    google_response = requests.get(google_url)
    google_soup = BeautifulSoup(google_response.text, 'html.parser')
    google_results = google_soup.find_all('h3', class_='t')
    for result in google_results:
        search_results.append(result.text)

    # 使用其他搜尋引擎繼續搜尋...

    return search_results

def main():
    team_name = input("請輸入球隊名稱:")
    team_info = search_team_info(team_name)
    for info in team_info:
        print(info)

if __name__ == "__main__":
    !pip install beautifulsoup4
    main()