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()